Home >Backend Development >PHP Tutorial >插数据库有关问题

插数据库有关问题

WBOY
WBOYOriginal
2016-06-13 10:36:00781browse

插数据库问题

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$sql = "insert into msg (id, userid, contant, oppeardate) values ('', '999', '$_POST[contant]', Now())";


看教程里是这么说的,now()会插入现在时间,但我用print $sql 发现,输出的还是now() ,不是当前时间,所以,在插入数据库的时候就会出现格式不对的错误,有知道啥原因的吗?

------解决方案--------------------
$sql = "insert into msg (id, userid, contant, oppeardate) values ('', '999', '$_POST[contant]', Now())";

这里的now是在mysql里执行的,在php里print $sql有什么用
------解决方案--------------------
set names gbk;
------解决方案--------------------
php date()函数,也可以获取当前时间戳。 
个人愚见,可以在PHP中获取当前时间,作为变量插入。
Statement:
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