I'm having trouble with a MySQL INSERT query. I've used this exact code in many places, and even in different pages on the same web server. I feel like I've tried every variation of INSERT query with no luck.
Here are a couple that I've tried so far:
$name = mysql_real_escape_string($_POST['name']);
$desc = mysql_real_escape_string($_POST['description']);
$priority = mysql_real_escape_string($_POST['priority']);
$due = mysql_real_escape_string($_POST['date_due']);
$assign = mysql_real_escape_string($_POST['assign_id']);
$assign_to = mysql_real_escape_string($_POST['assign_to']);
// There are more security measures here
$write = mysql_query ( "INSERT INTO main (name,desc,priority,given,due,status,assign,assign_to) VALUES ('$name','$desc',$priority,'$date','$due','New','$assign','$assign_to') " ) or die(mysql_error());
//The above yields this error:
//You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc,priority,given,due,status,assign,assign_to) VALUES ('test','test',4,'05/11/' at line 1
$write = mysql_query ("INSERT INTO main SET
name=$name,
desc=$desc,
priority=$priority,
given=$date,
due=$due,
status='new',
assign=$assign,
assign_to=$assign_to") or die(mysql_error());
//The above yields this error:
//You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc=test, priority=4, given=05/11/11, due=12/12/12, status='new', ass' at line 3
Any help would be greatly appreciated. I've searched for hours without a solution.