dth34653 2014-03-23 10:50
浏览 44
已采纳

mysql_insert_id()返回0

I've looked through the various answers and none of them seem to be helping. I have a simple Insert Query that is working as expected. Nothing special

$user_account_query = mysqli_query($dbc,"
        INSERT INTO ACCOUNT (EMAIL, IS_OPEN)
        VALUES ('$email', 1)")
        or die ('Could not add user: '. mysql_error());

It is successfully inserting the record into my db

enter image description here

I also have an auto-incrementing column in the table being called enter image description here

However, when I call

$message = mysql_insert_id();

I get 0. Does anyone have any advice on how to get the correct ID?

  • 写回答

2条回答 默认 最新

  • duanbai1974 2014-03-23 10:51
    关注

    You're mixing up mysql and mysqli

    $message = mysql_insert_id();
    

    should be

    $message = mysqli_insert_id($dbc);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部