dongzhong8691 2014-06-06 06:43
浏览 108

mysql_insert_id(); / last_insert_id(); 没有任何已知问题,不会返回最新的ID

mysql_insert_id(); / last_insert_id(); isn't returning latest ID without any known issue

$insert = "INSERT into `table` (`name`,`address`) VALUES ('$name', '$address')";                    mysql_select_db($database_A, $A);
$result = mysql_query($insert,$A) or die mysql_error();
$latest_id = mysql_insert_id($A); 
var_dump($latest_id);   

According to PHP manual I see any reason in the code why it's not returning the latest ID, instead it's always returning NULL or 0. It's happening in case of last_insert_id(); too.

This function returns 0 if the previous operation does not generate an AUTO_INCREMENT ID, or FALSE on MySQL connection failure.

Any idea?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计