I want to insert a few certain values from a php file, to my MySQL database, using a query.
I use the following code snippet:
mysql_query("INSERT INTO `text` VALUES ('', '$user_id', '$text', '"$categories"')");
but I get an error saying the following:
Parse error: syntax error, unexpected T_VARIABLE in
C:\xampp\htdocs\Project\Func\idea.func.php on line 10
Does anyone know what I’m doing wrong?
I have stated both variables, earlier, by making them into real escape strings. My MySQL table structure is as follows:
idea_id (auto)
user_id
text
categories
timestamp
You need to use string concatenation:
or get rid of the double quotes surrounding $categories: