【发布时间】:2010-05-31 23:05:00
【问题描述】:
我正在尝试检索插入到表“authors”中的最后一条记录的 id,并将检索到的 id 插入到“articles”表中;这是我的代码:
$title = mysql_real_escape_string($_POST[title]);
$body = mysql_real_escape_string($_POST[body]);
$category = mysql_real_escape_string($_POST[category]);
$insert_author="INSERT INTO authors (name) VALUES ('$title')";
$select_author= mysql_query("SELECT LAST_INSERT_ID()");
$authId = mysql_fetch_array($select_author);
$query="INSERT INTO articles (body, date, category, auth_id) VALUES ('$body', '$date_now', '$category', '$authId')";
这不起作用...
有什么想法吗?
提前致谢
毛罗
【问题讨论】:
-
“它不起作用”信息不足。你做了什么调试?究竟是什么不起作用?
标签: php lastinsertid