I have problem with my newly installed via repo for apache2, mysql, php and phpmyadmin. I was following this tutorial from digitalocean.
For now, my localhost is running and Ubuntu Apache2 default page is appeared. My phpmyadmin is also running and I have import several databases into it.
The issue is, everything in HTML are displayed. But everything that require mysql or mysqli are not functioning. I give two examples here:-
When try run using mysqli:-
$db = new mysqli_connect("localhost","adminmc","123adminmc456","moneychanger");
if($db->connect_errno > 0){
die('Unable to connect to database [' . $db->connect_error . ']');
}
The result is still like this:-
Unable to connect to database [Access denied for user 'root'@'localhost' (using password: NO)]
My first trial was using my root username and password. It was still prompt above error. I knew something is not right. I decided to use mysql instead.
When try run using mysql
$c = mysql_connect("localhost", "adminmc", "123adminmc456");
mysql_select_db("moneychanger");
$result = mysql_query("SELECT 'Hello, dear MySQL user!' AS _message FROM DUAL");
$row = mysql_fetch_assoc($result);
echo htmlentities($row['_message']);
Ive got HTTP ERROR 500 instead which mentioned "This page isn’t working".
I honestly not sure what I am doing wrong. I follow the tutorial and even my mysql and phpmyadmin working fine. But I couldn't even connect to database using basic mysqli and mysql php script. Please help me.