rrsnider
01-21-2002, 05:07 PM
I am trying to execute what I considered to be a simple command using MYSQL. I am working on an e-commerce site and I want to count the number of products in a category. I am trying to do a "SELECT COUNT" statement, but I can not get it to execute. Here are my statements:
$sql = "SELECT COUNT (*) FROM products WHERE Category =\"$cat\"";
$sql_result = mysql_query($sql,$connection) or die ("Could not execute count");
I get "Could not execute..." returned from the Query.
I know my table and variables are OK, because I am able to execute this query a few lines earlier.
$sql = "SELECT * FROM products WHERE Category = \"$cat\" LIMIT $j,$num_display";
$sql_result = mysql_query($sql,$connection) or die ("Could not execute query");
What am I doing wrong with my "SELECT COUNT" statement? I am guessing that I have a syntax problem by trying to perform the query from PHP (it works fine in MYSQL front).
$sql = "SELECT COUNT (*) FROM products WHERE Category =\"$cat\"";
$sql_result = mysql_query($sql,$connection) or die ("Could not execute count");
I get "Could not execute..." returned from the Query.
I know my table and variables are OK, because I am able to execute this query a few lines earlier.
$sql = "SELECT * FROM products WHERE Category = \"$cat\" LIMIT $j,$num_display";
$sql_result = mysql_query($sql,$connection) or die ("Could not execute query");
What am I doing wrong with my "SELECT COUNT" statement? I am guessing that I have a syntax problem by trying to perform the query from PHP (it works fine in MYSQL front).
