jeff5656 Posted October 3, 2008 Share Posted October 3, 2008 I get "Invalid query 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 '= '111', = 'fdsaf', = 'kjhk', = 'kj', = '', = 'm', = 'iyh', ' at line 2" for this code: <?php require('secure.php'); include "dateheader.php"; include "connectdb.php"; $newdate = date("Y-m-d", strtotime($_POST['rcf_date'])); $sql = "UPDATE icu SET $rm_loc = '" . $_POST['rm_loc'] . "', $patient = '" . $_POST['patient'] . "', $mrn = '" . $_POST['mrn'] . "', $age = '" . $_POST['age'] . "', $race = '" . $_POST['race'] . "', $gender = '" . $_POST['gender'] . "', $attg = '" . $_POST['attg'] . "', $rcf_date = '" . $_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'] . "', $lin = '" . $_POST['lin'] . "', $code = '" . $_POST['code'] . "', $allergy = '" . $_POST['allergy'] . "', $todo = '" . $_POST['todo'] . "', signoff_status = '" . $_POST['signoff_status'] . "', rcf_date2 = '$newdate' WHERE id_incr = ".$_POST['id_incr'].""; if (isset($sql) && !empty($sql)) { echo "<!--" . $sql . "-->"; $result = mysql_query($sql) or die ("Invalid query: " . mysql_error()); ?> <p> Done <?php } header("Location: displayactive.php"); ?> Link to comment https://forums.phpfreaks.com/topic/126925-invalid-query/ Share on other sites More sharing options...
F1Fan Posted October 3, 2008 Share Posted October 3, 2008 Remove the $ in front of each field name. PHP is seeing them as variables, not text. Link to comment https://forums.phpfreaks.com/topic/126925-invalid-query/#findComment-656512 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.