jeff5656 Posted March 19, 2008 Share Posted March 19, 2008 I cannot for the life of me see where in the code the error is. 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 'show, comments, signoff_status) VALUES('','pt name', '12345', '03/19/08', 'yo' at line 1 <?php include ("connectdb.php"); // grab the variables from the form $patient_name = $_POST['patient_name']; $mrn = $_POST['mrn']; $rcf_date = $_POST['rcf_date']; $your_name = $_POST['your_name']; $dx = $_POST['dx']; $show = $_POST['show']; $comments = $_POST['comments']; // insert the data into the database $query = "INSERT INTO xrayconf (id_incr, patient_name, mrn, rcf_date, your_name, dx, show, comments, signoff_status) VALUES('$id_incr', '$patient_name', '$mrn', '$rcf_date', '$your_name', '$dx', '$show', '$comments', 'a')"; mysql_query($query) or die(mysql_error()); echo "Thanks for submitting!"; ?> <table width="90%"><tr><td width="179" align="center"><a href="test.com">test.COM</a></td> </tr></table> Link to comment https://forums.phpfreaks.com/topic/96948-syntax-error/ Share on other sites More sharing options...
BlueSkyIS Posted March 19, 2008 Share Posted March 19, 2008 show is a MYSQL command. quote it if you have to use it. Link to comment https://forums.phpfreaks.com/topic/96948-syntax-error/#findComment-496101 Share on other sites More sharing options...
jeff5656 Posted March 19, 2008 Author Share Posted March 19, 2008 aha! thank you! Link to comment https://forums.phpfreaks.com/topic/96948-syntax-error/#findComment-496103 Share on other sites More sharing options...
trq Posted March 19, 2008 Share Posted March 19, 2008 show is a reserved word in sql. It will need to be surrounded in `backticks`, or better still, change that field name to something else. Link to comment https://forums.phpfreaks.com/topic/96948-syntax-error/#findComment-496104 Share on other sites More sharing options...
uniflare Posted March 19, 2008 Share Posted March 19, 2008 try: "INSERT INTO `xrayconf` (`id_incr`, `patient_name`, `mrn`, `rcf_date`, `your_name`, `dx`, `show`, `comments`, `signoff_status`) VALUES('$id_incr', '$patient_name', '$mrn', '$rcf_date', '$your_name', '$dx', '$show', '$comments', 'a')"; Link to comment https://forums.phpfreaks.com/topic/96948-syntax-error/#findComment-496105 Share on other sites More sharing options...
trq Posted March 19, 2008 Share Posted March 19, 2008 show is a MYSQL command. quote it if you have to use it. You need to use `backticks` not 'quotes'. But its much better to change the field name to something suitable. Link to comment https://forums.phpfreaks.com/topic/96948-syntax-error/#findComment-496106 Share on other sites More sharing options...
BlueSkyIS Posted March 19, 2008 Share Posted March 19, 2008 yes, you are correct. use `backticks` if necessary. also as suggested, it's better to use suitable field names instead. Link to comment https://forums.phpfreaks.com/topic/96948-syntax-error/#findComment-496136 Share on other sites More sharing options...
jeff5656 Posted March 19, 2008 Author Share Posted March 19, 2008 I think it would have taken a *long* time before I figured that out on my own! I changed it to show_what..... Link to comment https://forums.phpfreaks.com/topic/96948-syntax-error/#findComment-496293 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.