1

I have written below php code to connect 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, i.e. I am getting echo as 'Connected successfully'

<?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

O. Jones
  • 103,626
  • 17
  • 118
  • 172
Bogaso
  • 2,838
  • 3
  • 24
  • 54

1 Answers1

2

I just installed mysqlnd using apt-get install php-mysqlnd, and it works fine.

Bogaso
  • 2,838
  • 3
  • 24
  • 54