Jump to content

[SOLVED] Warning: mysql_num_rows()


Toddb1

Recommended Posts

ok so I got this 3rd party script (meaning I did not write it myself) I dont know enough about php to do that lol

 

Any how I get this error on only 1 page of my script I have been able to fix most everything myself. With the exception of 1 problem which some great ppl here were able to help me get fixed now I am going to the well one more time and asking for help. the error I get is this

 

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/fbcgoodr/public_html/SCARLITOSWAY.COM/tru/funcs.php on line 36

 

so when I go to the funcs.php page this is the line of code in question line 36

 

if (mysql_num_rows($last_sql) > 0) { 

 

for background info here is lines 33-52

 

	{
$pimp = "r".$game_id."_pimp";
$last_sql = mysql_query("select * from $pimp where code='$code[code]'");
if (mysql_num_rows($last_sql) > 0) {
	$last = mysql_fetch_array($last_sql);
	//echo "Level $game_id = $last[id]";
	$sql = mysql_query("select * from medals where game_id='$game_id' and user_id='$last[id]'");
	if (mysql_num_rows($sql) > 0) {
		while ($type=mysql_fetch_array($sql)) {
		//echo "Round $game_id = $type[medal]";
		for($i=1;$i<=4;$i++)
		{
		//echo $i;
  			if ($type[medal] == "level".$i."_1") { $medals[$i][1]++; }
  			if ($type[medal] == "level".$i."_2") { $medals[$i][2]++; }
  			if ($type[medal] == "level".$i."_3") { $medals[$i][3]++; }
  			}
		}
  		
  		}

 

I see this type of line several otherplace in the many different pages of code

(mysql_num_rows($last_sql) > 0)

so why does it not work here is there just a small mistake that I am over looking or a deeper problem I am missing can someone please help?

 

Thanks in advance

 

Link to comment
Share on other sites

Just before that line echo out the query

echo "select * from $pimp where code='$code[code]'"; 

make sure that $code

 is what it should be. 
This error is telling you there's something wrong with that query. 

 

just so I understand your are saying it should read

 

$pimp = "r".$game_id."_pimp";
   $last_sql = mysql_query(echo "select * from $pimp where code='$code[code]'");
   if (mysql_num_rows($last_sql) > 0) {

 

 

***Update***

scratch that I tried

$pimp = "r".$game_id."_pimp";
   $last_sql = mysql_query(echo "select * from $pimp where code='$code[code]'");
   if (mysql_num_rows($last_sql) > 0) {

 

and

 

$pimp = "r".$game_id."_pimp";
   $last_sql = mysql_query echo ("select * from $pimp where code='$code[code]'");
   if (mysql_num_rows($last_sql) > 0) {

 

and

 

echo $pimp = "r".$game_id."_pimp";
   $last_sql = mysql_query( "select * from $pimp where code='$code[code]'");
   if (mysql_num_rows($last_sql) > 0) {

 

and none worked did I misunderstand you?

 

Link to comment
Share on other sites

no. It should read.

$pimp = "r".$game_id."_pimp";
echo "select * from $pimp where code='$code[code]'"; 
   $last_sql = mysql_query("select * from $pimp where code='$code[code]'");
   if (mysql_num_rows($last_sql) > 0) {

which will echo the query out to your screen. So you can see what it's actually doing.

Link to comment
Share on other sites

no. It should read.

$pimp = "r".$game_id."_pimp";
echo "select * from $pimp where code='$code[code]'"; 
   $last_sql = mysql_query("select * from $pimp where code='$code[code]'");
   if (mysql_num_rows($last_sql) > 0) {

which will echo the query out to your screen. So you can see what it's actually doing.

 

lol ok thanks that got it I now get the error

select * from r1_pimp where code='7b5462b92828d5c9686f7fca13cfde43'
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/fbcgoodr/public_html/SCARLITOSWAY.COM/tru/funcs.php on line 37

 

and I know that "r1" stands for "round 1" which has been cleared from the database so that is the source for the error

 

Thanks so much for the insight you have helped me tremendously  ;D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

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.