Home  >  Article  >  Backend Development  >  【新手】插表有关问题

【新手】插表有关问题

WBOY
WBOYOriginal
2016-06-13 13:18:16713browse

【新手求助】插表问题
$query11 = "select last_insert_id()";
$result11 = mysql_query($query11);
$row = mysql_fetch_row($result11);
$id = $row[0];
$user = "xxx";
$type = "yyy";
$time = date("Y-m-d H:i:s");
echo "

$id | $user | $type | $time

";

/*
到这为止 输出正常
这是输出 
41 | xxx | yyy | 2012-08-18 14:56:43
*/

$query2 = "insert into finding values($id, $user, $type, $time)";
$result2 = mysql_query($query2);

紧接着的这两句执行之后怎么也插不到finding表中,
如果只插字符串可以,比如说$query2 = "insert into finding values($id, 'xxx', 'yyy', '2000-00-00 00:00:00')";
之后mysql_query($query2);没问题
求助各路大神!

这是表结构

+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id | int(8) | NO | PRI | NULL | |
| user | varchar(4) | NO | | NULL | |
| type | varchar(40) | NO | | NULL | |
| time | datetime | NO | | NULL | |
+-------+-------------+------+-----+---------+-------+


------解决方案--------------------
values($id, '$user', '$type', '$time')";这样试试
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