Jump to content

mysql fetch object problem


lengman

Recommended Posts

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/igweeccr/public_html/includes/functions.php on line 212

 

I'm very new to PHP and am in need for some help... this is the code..

 

$drop =mysql_query("SELECT * FROM casinos");

while($tard=mysql_fetch_object($drop)){
$per = mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$tard->owner'"));
if ($per->status == "Dead" || $per->status == "Banned"){
mysql_query("UPDATE casinos SET owner='0' WHERE casino='$tard->casino' AND owner='$tard->owner'");
}

}
$drop_bar =mysql_query("SELECT * FROM bar");
while($tard_bar=mysql_fetch_object($drop_bar)){
$per_bar = mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$tard_bar->owner'"));
if ($per_bar->status == "Dead" || $per_bar->status == "Banned"){
mysql_query("UPDATE bar SET owner='0' WHERE owner='$tard_bar->owner'");
}

 

Could the problem be with the database, basically this part of the code is a feature on my game... a bar script.... My friend uploaded all the data onto the database, but I can't find the bar on the database... Me and my friend wrote this code, so I don't need to go to the third party thread.

 

Thanks for the help in advance.

 

P.S Line 212 =

while($tard_bar=mysql_fetch_object($drop_bar)){

Link to comment
https://forums.phpfreaks.com/topic/132976-mysql-fetch-object-problem/
Share on other sites

I've gut this feeling...

 

Change:

$per_bar = mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$tard_bar->owner'"));

 

to

 

$result = mysql_query("SELECT * FROM users WHERE username='$tard_bar->owner'") or die(mysql_error);
$per_bar = mysql_fetch_object($result);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.