doubi1910 2013-02-22 16:26
浏览 420
已采纳

如何检查mysqli_connect是否成功?

I'm writing an installer script and I need to check if the user entered correct database information and therefore need to check if mysqli_connect was successful or not. A simple if-else will suffice.

  • 写回答

2条回答 默认 最新

  • douji9518 2013-02-22 16:33
    关注

    Like so:

    if( ! $db = mysqli_connect(...) ) {
        die('No connection: ' . mysqli_connect_error());
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?