jeff5656 Posted December 8, 2009 Share Posted December 8, 2009 I have this error, but an't seem to find where it is: 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 ' sex, comments, init_date, conf_date, signoff_status) VALUES('','bobby','', '' at line 1 if ($_POST['conf_date']==''){ $conf_date ='2030-01-01'; } else { $conf_date = date("Y-m-d", strtotime($_POST['conf_date'])); } $tx = mysql_real_escape_string($_POST['tx']); $primpulm = mysql_real_escape_string($_POST['primpulm']); $rheum = mysql_real_escape_string($_POST['rheum']); $dx = mysql_real_escape_string($_POST['dx']); $bx = mysql_real_escape_string($_POST['bx']); $bx_date = date("Y-m-d", strtotime($_POST['bx_date'])); $comments = mysql_real_escape_string($_POST['comments']); //add to main table $query = "INSERT INTO ild (id_incr, lname, fname, mrn, physician, primpulm, rheum, dx, bx, bx_date, $datedump, sex, comments, init_date, conf_date, signoff_status) VALUES('$id_incr','$lname','$fname', '$mrn', '$physician','$primpulm','$rheum', '$dx','$bx', '$bx_date','$dob','$sex', '$comments', '$init_date', '$conf_date', 'a')"; mysql_query($query) or die(mysql_error()); $pt_id = mysql_insert_id(); When I echo $query, it does indeed echo back all the values, before giving me the above error. Link to comment https://forums.phpfreaks.com/topic/184406-syntax-error/ Share on other sites More sharing options...
jeff5656 Posted December 8, 2009 Author Share Posted December 8, 2009 never mind i had an undeclared variable in the query. Link to comment https://forums.phpfreaks.com/topic/184406-syntax-error/#findComment-973423 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.