Hi Can any1 tell me what this error means ? Thanks. Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/pictures/public_html/functions.php on line 83 PHP:
Yes, sometimes you can have a typo and not notice it right away... for example: if your query result is $result but you typed $resut by mistake... you'll get that error.
It might not even be the spelling or an incorrect query - Make sure you aren't passing the actual query string into mysql_fetch_object(), it needs to be a result - Make sure you are passing the right variable nico_swd is right though. If you want real clarification post the code that caused the error.
ok , here is the code <? $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"; $res=mysql_query($sql) OR die(mysql_error()); $rows = 0; ?> <?php while($obj=mysql_fetch_object($res)) { if($obj->url=="") { $img="<a href='http://www.***.com/index.php?&username=$obj->username&phid=$obj->photosid''><img border=0 width=50 height=50 src='../pics/$obj->filename'></a>"; } else { $img="<a target='_blank' href='$obj->url'><img border=0 width=100 height=100 src='$obj->url'></a>"; } $id=$obj->photosid; $username=$obj->username; print $img; ?> <br /><a href="http://www.***.com/index.php?cmd=20&username=<? print $username; ?>">View <? print $username; ?>'s profile</a> <?php } ?> PHP:
what happens if you run the sql statement straight on the server ?(not from the program) Just to confirm that your query is correct.
It works fine, its when I add more sql statements its as if they 'colide' with each other, i.e to much sql.
try surrounding table and field names with the ` character `like`.`this` sometimes that takes care of the problem... but you should focus on the SQL... that's usually the problem. I doubt that it's a bummed PHP/MYSQL install. You could try it on another server if you think the software might be the problem.