无法使用 mysqli 连接到数据库
Cannot connect to a database with mysqli
我尝试连接数据库,但出现以下错误:
错误图片:
我连接数据库的代码:
使用mysqli_connect
代替mysqli
。
检查名为 web2_db
的数据库是否存在。
您的代码应如下所示:
$conn = new mysqli_connect('localhost', 'root', '', 'web2_db');
// btw protect your db with a password
if ($conn->connect_errno != 0)
die($errormsg);
我尝试连接数据库,但出现以下错误:
错误图片:
我连接数据库的代码:
使用
mysqli_connect
代替mysqli
。检查名为
web2_db
的数据库是否存在。
您的代码应如下所示:
$conn = new mysqli_connect('localhost', 'root', '', 'web2_db');
// btw protect your db with a password
if ($conn->connect_errno != 0)
die($errormsg);