I have a simple SQL query that continues to throw SQL syntax error. It looks like this:
$sql = "SELECT COUNT(*) AS TOTAL FROM PRODUCT WHERE ID_PRODUCT = ".$id;
$result = mysql_query($sql) or die(mysql_error());
What throws away:
You have an error in the SQL syntax; check the manual that matches your version of MySQL server for the correct syntax to use next to WHERE ID_PRODUCT = 1 'on line 1
I do not understand what is going on. Of course, if I try the request directly in phpMyAdmin, it will work without problems.
It returns the exact same error with SELECT *
Edit : ID_PRODUCT is a foreign key ...
Refresh . I also get the same error when replacing the variable $ id with a static value in the string $ sql WHERE ID_PRODUCT = 2and when protecting names with quotes.