Hi On a page of my site i am running a couple of different sql queries. I seem to have a problem though, I have wriiten some new code that seems to conflict with the code already on the page. Error message - Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/pictures/public_html/functions.php on line 83 Not Rated yet! Sample of code: (Code already on the site) function getRating($photoid) { $rating="Not Rated yet!"; $sql="select * from ratings where photosid=$photoid"; $res=mysql_query($sql); while($obj=mysql_fetch_object($res)) { $rating="Rated $obj->avgrating from $obj->numvotes votes"; } return $rating; PHP: Sample of code2: (Code I am trying to develop, works fine until put on the same page as the code above.) <?php $sql="select * from members,photos,ratings where members.username=photos.username and photos.photosid=ratings.photosid and numvotes>0 and gender='F' and approved='Y' and active=1 order by avgrating desc LIMIT 5"; $result=mysql_query($sql); while($object = mysql_fetch_object($result)) { echo "<td>\n"; if($object->url=="") { $img="<a href='http://****/index.php?&username=$object->username&phid=$object->photosid'><img border=0 width=50 height=50 src='../pics/$object->filename'></a>"; } else { $img="<a target='_blank' href='$object->url'><img border=0 width=50 height=50 src='$object->url'></a>"; } $idt=$object->photosid; $username=$object->username; print $img; ?> <br /><a href="http://****/index.php?cmd=20&username=<? print $username; ?>" class='footer'>View <? print $username; ?>'s profile</a> <?php echo "</td>"; { echo "\n\n"; } } ?> PHP:
It can be that query is errorneous so mysql does not return a valid result. Try mysql_error to show errors.