Jump to content

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resourc


twiggs462

Recommended Posts

A client of mine is having an issue with an admin area of their site that I never encountered before...

 

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

 

The code that is being referenced is:

 

// new sql to pull associated products for seleceted family

$restwoway = mysql_query("SELECT * FROM members order by name;");
$numrows=mysql_num_rows(restwoway);

if($numrows=0){
echo "Invalid entry";
}
else { ?>

 

Anyone see any errors here or... do you need me to provide additional details. I never seen this error before and not sure how to address it  :shrug:. Thank you for any ideas you might have.

Link to comment
Share on other sites

Ok. I just added this:

 

$restwoway = mysql_query($sql);
if (!$restwoway) {
die("I JUST GOT A QUERY ERROR!!!<br />Query is: $sql<br />Error is: ".mysql_error());
}

 

And it resulted in this:

 

I JUST GOT A QUERY ERROR!!!

Query is:

Error is: Query was empty

Link to comment
Share on other sites

Also, the if() statement will ALWAYS return true.

 

Does this mean that this is somehow just generally incorrect?

 

// new sql to pull associated products for seleceted family

$restwoway = mysql_query("SELECT * FROM members order by name;");
$numrows=mysql_num_rows($restwoway);

if($numrows=0){
echo "Invalid entry";
}
else { ?>

 

Sorry I am new to this and need to brush up... new more about PHP years back... had to learn ASP for work and now feel rusty  :-[

Link to comment
Share on other sites

Actually in this case, in your original code, look at the value you've passed to mysql_num_rows(). Is it missing something?

 

Not sure... I will need to look further.

 

What are variables supposed to start with?

 

I don't remember how to compare or what it should be compared to...

 

Assignment operators

Comparison operators

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.