PHP:如何插入(到Sql表中)变量并将其与日期函数连接起来


PHP : how to insert (into an Sql table) a variable and concatenate it with the date function

我一直试图插入一行到Sql数据库表中,该行的最后一列应该包含一个变量,我无法弄清楚如何将该变量与日期函数连接起来。问题变成了单引号

$SQL = "INSERT INTO news VALUES (NULL, '$user', '$text'.'date('Y-m-d H:i:s')')";

这个$text应该有一个"date now"函数在它之后被调用,这样我就会有它被插入到表中的日期…

谢谢

试试这个:

$sql = "INSERT INTO news VALUES (NULL, '$user', '$text<br>".date('Y-m-d H:i:s')."')";

你可以试试这个

$SQL = "INSERT INTO news VALUES (NULL, '$user', '".$text." now()')";