且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法使用mysqli_connect()连接到数据库

更新时间:2023-11-15 21:11:40

如果打开错误报告,则可以验证错误消息.

If you turn on error reporting you can validate the error message.

将以下内容添加到您的php脚本顶部.

Add the following to the top of your php script.

<?php 

ini_set('error_reporting' -1);
ini_set('display_errors', 'on');

//...

结果:

警告:mysqli_connect()期望参数5长,并给出字符串

Warning: mysqli_connect() expects parameter 5 to be long, string given

之所以没有收到mysqli_connect_error消息,是因为您提供给mysqli_connect的参数无效. 参见手册.

The reason you do not receive a mysqli_connect_error message, is that the arguments you supplied to mysqli_connect are invalid. See the manual.

mysqli_connect($host, $username, $password, $database_name, $port, $socket);