[英]Error 500 when I try to connect MySql with php's mysqli
I have written below php
code to connect MySQL DB: 我已经在下面的php
代码中编写了连接MySQL DB的代码:
<?php
// Connect to MySQL
$servername = "localhost";
$username = "user";
$password = "A11b22c33&";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
?>
However this code fails to make any connection. 但是,此代码无法建立任何连接。 All I am getting is below error: 我得到的只是错误以下:
currently unable to handle this request.
HTTP ERROR 500
However if I remove the connection portion of my code then my php
file working perfectly, ie I am getting echo as 'Connected successfully' 但是,如果我删除了代码的连接部分,那么我的php
文件就可以正常工作,即我收到的回显为“成功连接”
<?php
// Connect to MySQL
$servername = "localhost";
$username = "user";
$password = "A11b22c33&";
echo "Connected successfully";
?>
Can somebody help me to understand what went wrong? 有人可以帮助我了解问题出在哪里吗? I have checked username and password, and they are perfect 我已经检查了用户名和密码,它们是完美的
我刚安装mysqlnd
使用apt-get install php-mysqlnd
,并能正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.