我在表格中插入少量值,包括时间。但是除了datatime之外,所有其他attr都存储在这里。
查询:
$date = strtotime(date("Y-m-d H:i:s"));
$insertQuery2 = "INSERT INTO userpost(`userid`, `url`, `desc`, `preview`, `img_url`, `title` ,`hash`,`time`)
VALUES ('".$user_id."','".$url."','".$content."','".$Preview."','".$logo."','".$title_display."','".$hash."','".$rate."','".$date."')";
表:
mysql> desc userpost;
+---------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+---------------+------+-----+---------+-------+
| userid | varchar(40) | NO | PRI | | |
| url | varchar(255) | YES | | NULL | |
| desc | varchar(2048) | YES | | NULL | |
| preview | varchar(255) | YES | | NULL | |
| img_url | varchar(128) | YES | | NULL | |
| title | varchar(128) | YES | | NULL | |
| hash | varchar(128) | NO | PRI | | |
| rate | varchar(16) | YES | | NULL | |
| time | varchar(64) | YES | | NULL | |
+---------+---------------+------+-----+---------+-------+
答案 0 :(得分:2)
列数不匹配,,'".$rate."'
您在插入查询中添加了$ rate值
$insertQuery2 = "INSERT INTO userpost(`userid`, `url`, `desc`, `preview`, `img_url`, `title` ,`hash`,`time`)
VALUES ('".$user_id."','".$url."','".$content."','".$Preview."','".$logo."','".$title_display."','".$hash."','".$date."')";
添加了费率列及其值,
$insertQuery2 = "INSERT INTO userpost(`userid`, `url`, `desc`, `preview`, `img_url`, `title` ,`hash`,`rate`,`time`)
VALUES ('".$user_id."','".$url."','".$content."','".$Preview."','".$logo."','".$title_display."','".$hash."','".$rate."','".$date."')";