I am trying to insert values from $_POST into a MySQL table, and if I input numbers into the form, it works fine. However, whenever I type text, I get a message like “unknown column ‘exampleinput’ in ‘field list'”. I am a pretty amateur coder, so I may be missing something basic. Mysql fields are already set to VARCHAR. My code looks like this:
mysql_query("INSERT INTO users2
(username, primaryemail, password) VALUES($username, $newEmail, $newPassword)")
or die(mysql_error());
You need to add quotes around your input if you want to insert text into your table:
You should also consider using mysqli to perform your queries on your database as
mysql_*()functions are now deprecated.