introduction screenshots faq forum blog modules components download
Please use the search function and/or read the FAQ first.
-->

php mysql_fetch_array returned no rows



Posted by: mamadouabd
June 15, 2009 09:56AM
php mysql_fetch_array returned no rows. But when i submit the query directly to mysql, it returns the data. Here is my code :

include("config.php");

function BuildTable($result) {
$fieldCount = @mysql_num_fields($result);
for ($i=1; $i<$fieldCount; $i++) {
$fieldName = @mysql_field_name($result, $i);
}
$r=@mysql_fetch_array($result); //for testing
if($r != FALSE) //false is always returned although the query works on mysql
print("true");
else
print("false");
while($r=@mysql_fetch_array($result)) {
print("<tr>\n");
$num=@mysql_num_fields($result);
for($i=0;$i<$num;$i++) { //pour chaque champ
if(!is_null($r[$i])) {
if($i != 4) {
if($i == 3) {
print("<td>");
print("<a href='get_fichier.php?Fichier=".$r[4]."'>".$r[$i]."</a>");
print("</td>");
}
else {
print("<td>");
print($r[$i]);
print("</td>");
}
}
}
else
print("<td></td>");
}
print("</tr>\n");
}
}