I'm moving from an hosting service to another one and I've a problem on the DB connection with the new hosting provider.
Environment:
- PHP 5.4.43
- MySQL 5.6.32
$sqlHost = "localhost"; $sqlUser = "user"; $sqlPassword = "pwd"; $sqlDatabase = "databasename"; $mysqli = new mysqli($sqlHost, $sqlUser, $sqlPassword, $sqlDatabase); if($mysqli->connect_errno){ echo "SQL error: " . $mysqli->connect_error; exit; }
SQL error: Access denied for user 'user'@'localhost' (using password: YES)
In the old hosting provider the only difference was the MySQL version 5.5 and I never had a connection problem.
If I change the connection code with:
$conn = mysql_connect(HOST,DB_USER,DB_PASSWORD) OR die("Unable to connect");
mysql_select_db(DB,$conn);
I can correctly connect to the database with the user I created. What could be the problem?