开发者

Simple query not working

The simple query below is not returning any results. I can't see any errors in it. Any idea why it's not wo开发者_开发技巧rking?

$sqlStr3 = "SELECT loginid, 
                   username, 
                   created    
              FROM login         
          ORDER BY created DESC 
             LIMIT 200";

$result = mysql_query($sqlStr3);
$count = 1;  
$arr = array();
echo "<table class=\"samplesrec1edit\">";
    while ($row = mysql_fetch_array($result)) { 
            $dt = new DateTime($row["created"], $tzFrom); 
            $dt->setTimezone($tzTo);

            echo '<tr>';
            echo '<td class="sitename1edit2a">'.$count++.'.</td>';
            echo '<td class="sitename1edit1"><a href="http://www...com/.../members/index.php?profile='.$row["username"].'">'.stripslashes($row["username"]).'</a></td>';
            echo '<td class="sitename1edit2">'.$dt->format('F j, Y &\nb\sp &\nb\sp g:i a').'</td>';
            echo '</tr>';
        }

echo "</table>";


Change your query line from:

$result = mysql_query($sqlStr3);

to

$result = mysql_query($sqlStr3) or die("MySQL error: " . mysql_error());

Even if the query itself looks fine, there's a few bazillion reasons something else can be causing problems.

And if it's not already on, please turn on PHP's display_errors and do error_reporting(E_ALL). Maybe the query portions are fine and something else is blowing up (eg. a invalid value in $tzFrom).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜