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?

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
}

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

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.