I'm trying to loop a certain clause to get it to post pictures, descriptions, and sections. It says I have a:
Warning: Supplied argument is not a valid MySQL result resource in /var/www/html/projects/photos/photos.php on line 19
I'm not following why I have an error, but my script isnt executing for that reason. Are my loops correct and will it take the data from my database by ID rows? Cant seem to get it working correctly. HERES THE CODE:
<?php
$user = 'blahuser';
$pass = 'blahpass';
$db = 'pictures';
$conn = MYSQL_CONNECT("localhost",$user,$pass);
mysql_select_db($db,$conn);
$sql = "SELECT description,section FROM $table WHERE id=$id";
$result = mysql_query($sql,$conn) or die(mysql_error());
while ($newarray = mysql_fetch_array($result)) {
$description = $newarray['description'];
$section = $newarray['section'];
}
for ($id = 1; $id <= $mysql_num_rows($result); $id++ ) {
print '<TR>';
print '<TD width=33\%><img src=getdata.php?id='.$id.'&table='.$table.'width=404 height=295></TD>';
print '<TD width=33\%>'.$description.'</TD>';
print '<TD width=33\%>'.$section.'</TD>';
print '</TR>';
}
?>
</TABLE>
My vars are declared in the url: photos.php?table=zzzzz
Thanks,
-Steve