Jump to content

Invalid query: You have an error in your SQL syntax


jeff5656

Recommended Posts

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 '' at line 15"

 

Here is the entire code (not long):

I cant seem to find the error!

<?php
include "connectdb.php";

$check1_date = date("Y-m-d", strtotime($_POST['check1_date']));
$check2_date = date("Y-m-d", strtotime($_POST['check2_date']));
$check3_date = date("Y-m-d", strtotime($_POST['check3_date']));
$tp_date = date("Y-m-d", strtotime($_POST['tp_date']));

$sql = "UPDATE tx SET
patient = '" . $_POST['patient'] . "',
   	mrn = '" . $_POST['mrn'] . "',
   	check1 = '" . $_POST['check1'] . "',
   	check2 = '" . $_POST['check2'] . "',
   	check3 = '" . $_POST['check3'] . "',
   	comments = '" . $_POST['comments'] . "',
check1_date = '$check1_date',
check2_date = '$check2_date',
check3_date = '$check3_date',
signoff_status = '" . $_POST['signoff_status'] . "',
tp_date = '$tp_date'

WHERE id_incr = ".$_POST['id_incr']."";
if (isset($sql) && !empty($sql)) {
$result = mysql_query($sql) or die ("Invalid query: " . mysql_error());

}

header("Location: displayactive.php");

?>

Try updating your query as follows..

 

$sql = "UPDATE tx SET patient = $_POST['patient'], mrn = $_POST['mrn'], check1 = $_POST['check1'], check2 = $_POST['check2'], check3 = $_POST['check3'], comments = $_POST['comments'], check1_date = '$check1_date', check2_date = '$check2_date', check3_date = '$check3_date', signoff_status = $_POST['signoff_status'], tp_date = '$tp_date' WHERE id_incr = $_POST['id_incr']";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.