Page 1 of 1

worked then not worked

Posted: Thu Jun 26, 2003 7:05 pm
by stc7outlaw
I'm trying to loop a certain clause to get it to post pictures, descriptions, and sections. It says I have a:

Code: Select all

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:

Code: Select all

<?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

Posted: Fri Jun 27, 2003 3:16 am
by Wayne

Code: Select all

for ($id = 1; $id <= $mysql_num_rows($result); $id++ ) &#123;

should be

Code: Select all

for ($id = 1; $id <= mysql_num_rows($result); $id++ ) &#123;