Friday 25 January 2019

mysql - Unknown column '0' in 'field list'?





I have the following MySQL query:



INSERT INTO ipi_messages (Message_userID, Message_fromName, Message_fromEmail, Message_subject, Message_body) VALUES(`0`, `hope`, `thisworks@gmail.com`, `i hope`, `this works`)



My database schema is:



enter image description here



I cannot, for the life of me, figure out how that error is even possible. Why would MySQL try to find 0 as one of the columns? It is clearly not even in the column declaration piece of the code.



So why am I getting the error Unknown column '0' in 'field list'?


Answer



You need to use regular quotes ' for string values. Backquotes are used to enclose column and table names.


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...