Hi,
I have a query that suddenly fails when applying sprintf() to it
It looks like this:
$sqlcatquery = sprintf(mysql_query("SELECT categoryname, cart_id FROM categories WHERE BINARY categoryname='%s' AND cart_id=%d"),$category, $cart) OR die(mysql_error());
$row = mysql_fetch_array($sqlcatquery);
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 '%d' at line 1
applying singlequotes to "%d" still produces failure (it's also an integer, so it shouldn't be correct) produces:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/arioch/public_html/formprocessor.php on line 257
- and the result set is empty.
Changing categoryname to "%d" (BINARY produces integer, correct?)
Gives me:
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 '%d AND cart_id='%d'' at line 1
How do I get around this?