Current location: Hot Scripts Forums » Programming Languages » PHP » Php problem, Mysql fetch arrays (or something)


Php problem, Mysql fetch arrays (or something)

Reply
  #1 (permalink)  
Old 07-27-05, 07:25 AM
xxvatarxx xxvatarxx is offline
Wannabe Coder
 
Join Date: May 2005
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Php problem, Mysql fetch arrays (or something)

i have a php file and its throwing up these errors

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/xxvatarx/public_html/games/cats.php on line 5


Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/xxvatarx/public_html/games/cats.php on line 13




line 5 =
PHP Code:

$cat mysql_fetch_object($qr1); 

line 13 =
PHP Code:

while( $row mysql_fetch_object($qr1) ){ 

Any ideas?


this is the code of the page


PHP Code:

<?

include("common.php");

$qr1 mysql_query("SELECT * FROM cats WHERE id=$id");
$cat mysql_fetch_object($qr1);
$seo_title $sitename." - ".$cat->name." Games";

include(
"header.php");
?>
<h2><?=$cat->name?> Games</h2>
<?
$qr1 
mysql_query("SELECT * FROM games WHERE cat=$id AND status=1");
while( 
$row mysql_fetch_object($qr1) ){
?>
<table width=100%>
<tr>
<td align=left width=25%>
<a href="<?=$siteurl?>/games.php?id=<?=$row->id?>" class="nav"><img src="<?=$siteurl?>/uploads/thumb/<?=$row->thumb?>" border=0 width="70" height="59"></a>
</td>
<td align=left><div align=left>
<strong><a href="<?=$siteurl?>/games.php?id=<?=$row->id?>" class="nav"><?=stripslashes($row->name)?></a></strong><br>
<?=stripslashes($row->description)?><br>
<a href="<?=$siteurl?>/games.php?id=<?=$row->id?>" class="nav">Play</a>
</div></td>
</tr>
</table>
<br>
<?
}
?>
<?
include("footer.php");
?>
Anyone know? Im new to using db's in php so im pretty sure its something like that. Like itstrying to retrieve information from the database but its not responding. Anyone got any idea?

Last edited by xxvatarxx; 07-27-05 at 08:11 AM.
Reply With Quote
  #2 (permalink)  
Old 07-27-05, 08:23 AM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Code:
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/xxvatarx/public_html/games/cats.php on line 5
99% of the time this is caused by no results being returned from the query. The error occurs because you're trying to do something with data that doesn't exist.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Reply With Quote
  #3 (permalink)  
Old 07-27-05, 10:33 AM
xxvatarxx xxvatarxx is offline
Wannabe Coder
 
Join Date: May 2005
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
thnx, that helped alot more than you'd think, managed to fix it kinda i replaced the query with this
Quote:
$sql = 'SELECT * FROM `cats` ORDER BY `id` ASC LIMIT 0, 30';
But now it is only turning up the first catagory, how do i get it to show up all the catagories?
Reply With Quote
  #4 (permalink)  
Old 07-27-05, 10:51 AM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
You may need to do something like this:

$sql = 'SELECT * FROM `cats` ORDER BY `id` WHERE 'id' <> '' ASC LIMIT 0, 30';
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM
php mysql updating problem kevinb PHP 2 11-06-04 03:15 PM
php and mysql problem AccelEric PHP 1 10-20-04 07:37 PM
another php search mysql problem sumogray PHP 6 06-28-04 08:03 AM


All times are GMT -5. The time now is 06:59 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.