jeff5656 Posted October 2, 2008 Share Posted October 2, 2008 I get 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 'lines, code, allergy, todo, signoff_status) VALUES('','109', 'test', '12345',' at line 1 With this code: I can't figure out where th error is. <?php require('secure.php'); // include the config file with the needed variables include ("connectdb.php"); // grab the variables from the form $rm_loc = $_POST['rm_loc']; $patient = $_POST['patient']; $mrn = $_POST['mrn']; $attg = $_POST['attg']; $rcf_date = $_POST['rcf_date']; $newdate = date("Y-m-d", strtotime($_POST['rcf_date'])); $dx = $_POST['dx']; $pmhx = $_POST['pmhx']; $diet = $_POST['diet']; $meds = $_POST['meds']; $sed = $_POST['sed']; $ivf = $_POST['ivf']; $abx = $_POST['abx']; $cx = $_POST['cx']; $prophylaxis = $_POST['prophylaxis']; $vent = $_POST['vent']; $lines = $_POST['lines']; $code = $_POST['code']; $allergy = $_POST['allergy']; $todo = $_POST['todo']; // insert the data into the database echo $id_incr; echo "<br>"; $query = "INSERT INTO icu (id_incr, rm_loc, patient, mrn, attg, rcf_date, rcf_date2, dx, pmhx, diet, meds, sed, ivf, abx, cx, prophylaxis, vent, lines, code, allergy, todo, signoff_status) VALUES('$id_incr','$rm_loc', '$patient', '$mrn', '$attg', '$rcf_date', '$newdate', '$dx', '$pmhx', '$diet', '$meds', '$sed', '$ivf', '$abx', '$cx', '$prophylaxis', '$vent', '$lines', '$code', '$allergy', '$todo', 'a')"; mysql_query($query) or die(mysql_error()); echo "Patient added to list"; header("Location: displayactive.php"); ?> Link to comment https://forums.phpfreaks.com/topic/126814-sql-syntax-error/ Share on other sites More sharing options...
revraz Posted October 2, 2008 Share Posted October 2, 2008 LINES is a mysql reserved word, you need to either change that fieldname or use `backticks` around it. http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html Also, your header won't work, since you echo to the browser before it. Link to comment https://forums.phpfreaks.com/topic/126814-sql-syntax-error/#findComment-655947 Share on other sites More sharing options...
jeff5656 Posted October 2, 2008 Author Share Posted October 2, 2008 Thanks! It's amazing dreamweaver is not "smart" enough to know if you're using a reserved word as a variable. Link to comment https://forums.phpfreaks.com/topic/126814-sql-syntax-error/#findComment-655954 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.