
ht1080z
User
Dec 6, 2011, 3:54 PM
Post #1 of 3
(624 views)
Shortcut
|
|
php date to mysql datetime record update
|
Can't Post
|
|
Hello, I try to update in my table the mysql datetime field but no luck. i managed to convert my 26/05/2011 php date format to 2011-05-26 00:00:00 with:
$time = strtotime( @$_REQUEST['from'] ); $from = date("Y-m-d H:i:s", $time); ..... and $to as well but cannot update the field 'from' and 'to' in my db:
$query = "UPDATE `{$TABLE_PREFIX}accoms` SET title = '".mysql_escape( $_REQUEST['title'] )."', type = '".mysql_escape( $_REQUEST['type'] )."', category = '".mysql_escape( $_REQUEST['category'] )."', from = '".mysql_escape($from)."', to = '".mysql_escape($to)."', desc = '".mysql_escape( $_REQUEST['desc'] )."', info = '".mysql_escape( $_REQUEST['info'] )."', updatedByUserNum = '".mysql_escape( $CURRENT_USER['num'] )."', updatedDate = NOW() WHERE createdByUserNum = '".mysql_escape( $CURRENT_USER['num'] )."'"; mysql_query($query) or die("MySQL Error:<br/>\n". htmlspecialchars(mysql_error()) . "\n"); for date update getting 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 'from = '2011-01-04 00:00:00', to = '2011-01-10 00:00' at line 6 Please advise! Karls
|