I am trying to use PHP variables in an INSERT SQL statement. Ive seen previous answers to this but can not get mine to work. Here is the code..
mysql_query("INSERT INTO message (message_id, from, content) values ('', " . $uid . ", 'test message content')");
The main problem is that
fromis a reserved word and should be in backticks.But I’d also advise you to stop using the deprecated
mysql_*functions. I’d recommend that you take a look at PDO and prepared statements with parameters.