开发者

MySQL Query not printing out data

I'm trying to retrieve some data from my table only for some reason I cant get it to return anything.

<?php

$curr_uemail = mysql_query("select * from produgg_users where produgg_users.id = ".$usersClass->userID().") or die(mysql_error())");    

$arr_uemail = mysql_fetch_array($data);

while($arr_uemail = mysql_fetch_array($data)) 
{
echo $arr_uemail['em开发者_JAVA技巧ail'];
}

/*For Debugging purposes
echo $usersClass->userID();*/

?>

Can anybody see anything wrong with my syntax?


There are a lot of errors.

The first is

$curr_uemail = mysql_query("select * from produgg_users where produgg_users.id = ".$usersClass->userID()) or die(whoops);

The second you shouldn't call mysql_fetch_assoc before while, because if the result contains only 1 Record it would never enter in the while

The final code is:

$curr_uemail = mysql_query("select * from produgg_users where produgg_users.id = ".$usersClass->userID()) or die('whoops');

while($arr_uemail = mysql_fetch_array($curr_uemail)) {
echo $arr_uemail['email'];
}

As stated by marc if you have only one records than this could become:

$curr_uemail = mysql_query("select * from [etc]") or die('whoops');    
$arr_uemail = mysql_fetch_array($curr_uemail);
echo $arr_uemail['email'];


I told you the first error via my comment. But please enable error handling and do what the interpreter will tell you.

error_reporting(E_ALL);
ini_set('display_errors', 1);

What also can be erroneous, is this statement here:

while($arr_uemail = mysql_fetch_array($data)) 

You should enclose it with parentheses or the interpreter may warn you.

while(($arr_uemail = mysql_fetch_array($data))) 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜