Add date to MySQL using PHP -
i trying add current date mysql table using php. have following code:
$date = date('y-m-d'); mysql_query("insert book_order values($date)") or die (mysql_error());
mysql returns error:
incorrect date value: '1996' column 'date_order' @ row 1
date_order
attribute type date
.
i've tried echo
$date
value , prints out 2013-05-12
why can't add date table , strange 1996?
if can send local date use:
mysql_query("insert book_order values(now())");
the problem because sql have typo - $date
variable must quoted:
mysql_query("insert book_order values('$date')") or die (mysql_error());
in addition, if not work edit question , paste result sql explain book_order
Comments
Post a Comment