Home > Backend Development > PHP Tutorial > 怎么向mysql数据库中插入当前时间字段

怎么向mysql数据库中插入当前时间字段

WBOY
Release: 2016-06-13 10:52:19
Original
1245 people have browsed it

如何向mysql数据库中插入当前时间字段?
$conn->prepare("INSERT INTO aaa(name,mydate) VALUES (trim(:name),now())");
这条无法执行,请问应该如何改?

------解决方案--------------------
无法执行报啥错误
mydate是啥类型,改为DATETIME
------解决方案--------------------
$conn->prepare("INSERT INTO aaa(name,mydate) VALUES (trim(‘name’),now())");

还有就是,不知道在程序里面怎样调试,可以放到mysql管理工具里面去运行一下这句sql语句,如果不正确会提示你为什么不正确,在慢慢调试修改就可以了。
------解决方案--------------------
Insert into `aaa` Set name='abc',mydate='".time()."'

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template