-1
我在这里有这样一小段代码片段:日期保存到MySQL数据库为0000-00-00
// Insert data into mysql
$data = "'".date('Y-m-d', strtotime(str_replace('-', '/', $data3)))."'";
echo $data;
$sql="INSERT INTO assets(dateOfPurchase) VALUES ('$data')";
$result=mysql_query($sql);
我得到这个错误:
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 '2015-10-11'
请帮我整理出来。
编辑你的问题在变量替换后显示'$ sql'。 –