On my webpage I'm using PHP and I run it in Ubuntu 16.04.
It works well.
Then I try to run it on CentOS 5.11 (I know centOS 5.11 is out of date, but for many reasons I must I use it).
And the result is my webpage doesn't work.
I show this error:
Fatal error: Uncaught exception 'mysqli_sql_exception' with message 'Permission denied' in /var/www/html/IPU-GUI/website2/templates/sql_login.php:3 Stack trace: #0 /var/www/html/IPU-GUI/website2/templates/sql_login.php(3): mysqli_connect('127.0.0.1', 'root', '123456', 'ipu1') #1 /var/www/html/IPU-GUI/website2/sip.php(30): require_once('/var/www/html/I...') #2 {main} thrown in /var/www/html/IPU-GUI/website2/templates/sql_login.php on line 3
Here is my code:
<?php
require '../functions/server_info.php';
$conn = mysqli_connect($sql_login["host"], $sql_login["username"], $sql_login["password"], $sql_db);
if (!$conn) {
echo mysqli_connect_error();
}
?>
And server_info.php
$sql_login = array(
"host"=>"127.0.0.1",
"port"=>"3306",
"username"=>"root",
"password"=>"123456"
);
$sql_db = "ipu1";
UPDATE: I try to fix this error by change "host"=>"127.0.0.1" to "host"=>"localhost" it works. But I don't know what wrong? What different from "127.0.0.1" and "localhost".