I use mariadb as my database and phpmyadmin to access on databases web on Linux. Although I am able to connect to the database on the commandline as root but cannot check connection to the database with PHP? I am unsure if there's something I'm missing out?
My HTML/PHP Code:
<!DOCTYPE HTML>
<html>
<body>
<?php
$host = 'localhost';
$user = root';
$password = '';
$db = 'testdb';
$dbconnect=mysqli_connect($host,$user,$password,$db);
if ($dbconnect->connect_error) {
die("Database connection failed.");
}
?>
</body>
</html>
What my web page displays:
"connect_error) { die("Database connection failed: " . $dbconnect->connect_error); } ?> "
What I've tried:
- Changing to
bind-address 0.0.0.0
. - Allowing the
port 3306
through firewall.
Still the same display.