php mysql_insert_id();不工作 [英] php mysql_insert_id(); not working
问题描述
我希望从这里得到一些帮助.
Hi guys I was hoping from some help here, please.
我对表有一个INSERT查询,完成后,我打电话给
I have a INSERT query to a table, after this is done I am calling:
mysql_insert_id();
为了将插入到表中的最后一个ID发送到下一页,如下所示:
In order to send the last ID inserted into the table to the next page like this:
$insertGoTo = "confirm_booking.php?booking_ID=" .$_POST['booking_ID']. "";
不幸的是,它不起作用,我得到的只是一个零.
Unfortunately it does not work, all I get is a zero.
我要插入的表具有一个自动递增编号,并且将值插入其中.
The table I am inserting into has an auto increment number and values are inserted into it.
我也尝试过SELECT MAX(id) FROM mytable
.这也不行.
I have also tried SELECT MAX(id) FROM mytable
. This dosn't work neither.
我知道这个问题已经被讨论过了.我读了所有帖子,但没什么有用的.
I know that this problem has been talked about already. I read all posts but nothing came useful.
非常感谢Francesco
Many thanks Francesco
推荐答案
在生成链接时,必须使用MySql_Insert_Id()返回的值:
You have to use the value returned by MySql_Insert_Id () when you generate your link:
// your query
$newId = MySql_Insert_Id ();
$insertGoTo = "confirm_booking.php?booking_ID=" . $newId;
这篇关于php mysql_insert_id();不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!