Jump to content
MakeWebGames

Getting An Not A Vaid MYSQL Error, Please Help


Recommended Posts

I am getting a this error about 50 times.

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource on line 180

172 $q=mysql_query("SELECT * FROM `users` WHERE `location` = '$r[cityid]'");

173 $pricepay=mysql_fetch_array($q)*$r['citytaxprice'];

174 mysql_query("UPDATE users SET money=money+$pricepay WHERE userid=$r[cityowner]");

175 }

176 $newcq=mysql_query("SELECT * FROM`cities`");

177 while($newr=mysql_fetch_array($newcq))

178 {

179 $daf=mysql_query("SELECT * FROM `users` WHERE `location` = '$newr[cityid]");

180 if(mysql_num_rows($daf) > $newr['citymost'])

181 {

182 $rowstoupdate=mysql_num_rows($daf);

183 mysql_query("UPDATE cities SET citymost=$rowstoupdate WHERE cityid=$r[cityid]");

184 mysql_query($query,$c) or die("\nError Executing Query 1 for updating users $i to $next\n$query\n".mysql_error()."\nError Code:".mysql_errno());

185 }

Link to comment
Share on other sites

	$q = $db->query('SELECT COUNT(userid) FROM `users` WHERE `location` = '.$r[cityid]);
$pricepay = ($db->fetch_array($q) * $r['citytaxprice']);
$db->query('UPDATE `users` SET `money` = `money` + $pricepay WHERE `userid` = '.$r[cityowner]);
}
$newcq = $db->query('SELECT * FROM`cities`');
    while( $newr = $db->fetch_array($newcq) ) {
$daf = $db->query('SELECT * FROM `users` WHERE `location` = '.$newr[cityid]);
$rowstoupdate = $db->num_rows($daf);
if ( $rowstoupdate > $newr['citymost'] ) {

$db->query('UPDATE `cities` SET `citymost` = '.$rowstoupdate.' WHERE `cityid` = '.$r[cityid]);
// mysql_query($query,$c) or die("\nError Executing Query 1 for updating users $i to $next\n$query\n".mysql_error()."\nError Code:".mysql_errno());
} 

You are running mc v2 right?

Link to comment
Share on other sites

Try this:

 

$fetch = mysql_query('SELECT COUNT(`userid`) AS `count` FROM `users` WHERE `location` = '.$r['cityid']) or die(mysql_error().' on line '.__LINE__);
$pricepay = (mysql_result($fetch, 'count') * $r['citytaxprice']);
mysql_query('UPDATE `users` SET `money` = (`money` + '.$pricepay.') WHERE `userid` = '.$r['cityowner']);
}
$cities = mysql_query('SELECT `cityid`,`citymost` FROM `cities`') or die(mysql_error().' on line '.__LINE__);
while($fsoc = mysql_fetch_assoc($cities))	{
$rpos = mysql_query('SELECT COUNT(`userid`) AS `count` FROM `users` WHERE `location` = '.$fsoc['cityid']) or die(mysql_error().' on line '.__LINE__);
$rows = mysql_num_rows($rpos);
if($rows >= $fsoc['citymost'])	{
	mysql_query('UPDATE `cities` SET `citymost` = '.$rows.' WHERE `cityid` = '.$fsoc['cityid']) or die(mysql_error().' on line '.__LINE__);
	if(!empty($query))	{
		mysql_query($query) or die(mysql_error().' on line '.__LINE__);
	}
}
}
Link to comment
Share on other sites

Try this:

 

$fetch = mysql_query('SELECT COUNT(`userid`) AS `count` FROM `users` WHERE `location` = '.$r['cityid']) or die(mysql_error().' on line '.__LINE__);
$pricepay = (mysql_result($fetch, 'count') * $r['citytaxprice']);
mysql_query('UPDATE `users` SET `money` = (`money` + '.$pricepay.') WHERE `userid` = '.$r['cityowner']);
}
$cities = mysql_query('SELECT `cityid`,`citymost` FROM `cities`') or die(mysql_error().' on line '.__LINE__);
while($fsoc = mysql_fetch_assoc($cities))	{
$rpos = mysql_query('SELECT COUNT(`userid`) AS `count` FROM `users` WHERE `location` = '.$fsoc['cityid']) or die(mysql_error().' on line '.__LINE__);
$rows = mysql_num_rows($rpos);
if($rows >= $fsoc['citymost'])	{
	mysql_query('UPDATE `cities` SET `citymost` = '.$rows.' WHERE `cityid` = '.$fsoc['cityid']) or die(mysql_error().' on line '.__LINE__);
	if(!empty($query))	{
		mysql_query($query) or die(mysql_error().' on line '.__LINE__);
	}
}
}
Thank you. I believe it works now. There is no error. when i run the page i get this.

User has been notified. I appreciate all the help I have been getting from you guys.

Admin pls delete this thread now.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...