插入新值php时出错了

时间:2016-05-25 22:26:36

标签: php sql

我正在尝试运行此代码,但插入时间值有问题,我从$ long获取时间值我确定我写错了方式我希望有人可以给我正确的方式,并且时间在database是int

 $now = date("Y-m-d H:i:s");
 $long = strtotime($now); 
 if ((isset($_GET['recordID'])) && ($_GET['recordID'] != "")) {
     $insertSQL = sprintf("INSERT INTO tblbills(idUser , intProduct_id , intPrice , intQuantity , time=%s)   
  SELECT tbltrolley.idUser , tbltrolley.idProduct , tbltrolley.intPrice , tbltrolley.intQuantity
  FROM tbltrolley
  WHERE tbltrolley.intOrderDone=%s AND tbltrolley.idUser=%s 
  ",
                      GetSQLValueString($long, "int"),
                       2,
                       GetSQLValueString($_GET['recordID'], "int"));

1 个答案:

答案 0 :(得分:-1)

感谢大家,我只是想知道如何解决它,这是修复后的代码



$now = date("Y-m-d H:i:s");
	 $long = strtotime($now); 
if ((isset($_GET['recordID'])) && ($_GET['recordID'] != "")) {
  $insertSQL = sprintf("INSERT INTO tblbills(idUser , intProduct_id , intPrice , intQuantity , time)   
  SELECT tbltrolley.idUser , tbltrolley.idProduct , tbltrolley.intPrice , tbltrolley.intQuantity , '$long'
  FROM tbltrolley
  WHERE tbltrolley.intOrderDone=%s AND tbltrolley.idUser=%s ",
                   2,
   		   GetSQLValueString($_GET['recordID'], "int"));