Jump to content

[SOLVED] mysql_num_rows(): supplied argument is not a valid MySQL result


xiao

Recommended Posts

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

 

I call it like this:

if(mysql_num_rows(mysql_query($qryBehuizing)) == 0){
echo "<option>Geen producten gevonden</option>";
}else{

 

Query:

$qryBehuizing = mysql_query("SELECT p.products_id, p.products_model, p.products_price, p.products_image, pd.products_name, pc.categories_id FROM products p, products_description pd, products_to_categories pc WHERE pc.categories_id = '".$instBC."' AND p.products_id = pd.products_id AND p.products_id = pc.products_id AND pd.language_id = '".$instT."' AND p.products_price <=50 GROUP BY pd.products_name ORDER BY p.products_price") or die(mysql_error());

 

What am I doing wrong?

Link to comment
Share on other sites

You could start by unbundling your code so it gives better information:

 

$qryBehuizing = " ... whatever ...";
$result = mysql_query($qryBehuizing) or die("Error ". mysql_error(). " with query ". $qryBehuizing);
if (mysql_num_rows($result) == 0) {
// etc
}

Link to comment
Share on other sites

Didn't think that far  ;)

 

It says:

Error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #6' at line 1 with query Resource id #6
Link to comment
Share on other sites

In phpMyAdmin I get this error when inserting the query:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"SELECT p.products_id, p.products_model, p.products_price, p.products_image, pd.' at line 1
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.