There is a form on the site that works for all users clearly. But then one user began to give an error:

"SQL syntax; 'FROM `price` WHERE id_item='11051'' at line 1.

I just can’t understand if the request is incorrect, would it not work for everyone then? And only one user fails ...
in the script it looks like this:

 $query = mysql_query("SELECT naimenovanie, {$price} FROM `price` WHERE `id_item`='$id_item'") or die (mysql_error()); while ($row = mysql_fetch_array($query)) { $izdelie=$row['naimenovanie']; $cena=$row[$price]; } 
  • 2
    And what does the full query look like? and why id as a string, and not as a number? And why can the user see errors from the database? - Alexey Shimansky
  • And how this request is formed is also very interesting ... - Akina
  • one
    @ Alexey Shimansky are lovers or die(mysql_error()) (or whatever it is) apparently - teran
  • The question can be edited, if that. Add there also how and whence this $id_item - teran turns out
  • what is passed in $price ? if there is a line like 10 000 (with a space), then the request will obviously not work. - teran

2 answers 2

'FROM price WHERE id_item =' 11051 '' at line 1.

Syntactic error, look at the value id_item -> id_item = '11051' '

    The $ price variable is an empty string. MySQL does not understand where FROM is after the decimal point.