服务器移动后,$ msqli-> insert_id始终返回'0'

时间:2015-11-21 22:48:19

标签: php mysql mysqli

直到本周服务器移动(由托管服务提供商),这段代码才能完美运行:

$conn = new mysqli('localhost','dbuser','dbpass','dbname');
$conn->set_charset("utf8");
$new_tester = $conn->prepare("INSERT INTO testers (tid,first_name,last_name,t_email,company,last_login,ip_address) VALUES (NULL,?,?,?,?,NULL,?)");
$new_tester->bind_param('sssss',$first_name,$last_name,$t_email,$up_company,$ip_address);
$new_tester->execute();
$userid = $conn->insert_id;
$new_tester->store_result();
$new_tester->close();
print($userid);

自移动以来,insert_id总是返回0.我在store_result()和close()之前/之后用insert_id移动了行,但它仍然不起作用。

对于记录,它在我的本地计算机上按预期工作。我的机器和服务器都使用PHP 5.6和MySQL 5.0.11。 AUTO_INCREMENT正在使用中。

0 个答案:

没有答案