worked then not worked

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
stc7outlaw
Forum Newbie
Posts: 21
Joined: Mon Jun 09, 2003 9:36 pm

worked then not worked

Post 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
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post 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;
Post Reply