For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > May 2006 > Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in
macca

2006-05-31, 7:00 pm

Hi, I am trying to display all the records from my table in an HTML
table where the posted var $gallery_name.



All i get is this error:


Warning: mysql_num_rows(): supplied argument is not a valid MySQL
result resource in
/home/macca/public_html/somethingartistic/galleries/gallery.php on line
60


It doesnt seem to like the use of mysql_num_rows($result) in the for
loop, yet it works fine on my test machine,

any suggestions why would be greatfully appreciated, or maybe an
alternative way to run the loop for the number of records to from my
table.


Heres the table:



echo '<table class="galleries" width="750" cellpadding="0"
cellspacing="0" bgcolor="#dbe4f5"><tr>';


$gallery_name = $_POST['gallery_name'];

$query = "SELECT * FROM galleries WHERE artist_name =
'$gallery_name'";
$result = mysql_query($query, $dbh);


for ($i = 0; $i < mysql_num_rows($result); $i++ )
{
$image_name = mysql_result($result, $i, "image_name");
$display_width = mysql_result($result, $i, "display_width");
$display_height = mysql_result($result, $i, "display_height");

$width = $display_width / 3;
$height = $display_height / 3;

if($i % 2)
{
$tablerow="</tr><tr>";
}
else
{
$tablerow="";
}


echo '

<td>
<br />


<div align="center">
<form action="view.php" method="post">
<input type="hidden" name="picname"
value="'.$image_name.'" />
<input type="image" src="'.$gallery_name.'/'.$image_name.'"
width="'.$width.'" height="'.$height.'" alt="Gallery picture"
value="submit" />
</form></div><br />

</td>
'.$tablerow.'


';

}
?>
</table>



Thanks

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com