View Full Version : Update datetime error

11-19-2007, 03:45 AM
Drawing a blank as to what I am doing wrong. I'm trying to update a DATETIME field with the following:

$query .= ", commission=" . $_post['commission'] . ", date_modified='" . date("Y-m-d H:i:s") . "', modified_by='" . $_SESSION['user_name'] . "'";
$query .= " WHERE part_id='" . $_POST['part_id'] . "'";

I keep getting the following error:
Query Error!
1064 : 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 ' date_modified='2007-11-18 22:34:19', modified_by='Alan' WHERE part_id='0007~'' at line 1

I know I'm staring at the problem... but where?


11-19-2007, 05:00 AM
It looks like you're missing quotes around the commision value. Also, use the MySQL function NOW() for the datetime if you want to set it to the current time. If you still get an error post the entire query.

11-19-2007, 07:49 AM
i just tried to make
echo $query;
this way I can see if there is anything not normal

It looks like you have no quotation marks around
commission=value ( should be: commission='value' )

also not $_post, but use$_POST

Try this:
$query .= ", commission='" . $_POST['commission'] . "', date_modified='" . date("Y-m-d H:i:s")
. "', modified_by='" . $_SESSION['user_name'] . "'";
$query .= " WHERE part_id='" . $_POST['part_id'] . "'";
// debug
echo $query;

11-20-2007, 02:17 AM
Thanks... The commission which is a numeric value was missing.