3
I uploaded my website (using Filezilla) using php/mysql. On the localhost it works perfectly but on the external server it doesn’t. The following error appears:
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost
<?php
try {
$pdo = new PDO ('mysql:host=localhost;dbname=***', '***', '***');
}
catch (PDOException $e) {
exit('Database error.');
}
?>
What could be missing?
Is there an error message? Or the result is a blank screen?
– Leonel Sanches da Silva
Thank you, I edited my question
– Miguel
Can you explain the line in which there is the connection statement to the database? You can also check if the connection data is pointing to the credentials provided by your hosting provider?
– Leonel Sanches da Silva
Changes the location of the bank, should ta as localhost, when you move up the application, have change, and put the external link of the bank.
– leonardovff
I put it on top, and I think I already know. Must have something to do with "mysql:host=localhost"? but what instead?
– Miguel
In place of
exit('database error')
letprint_r($e)
) this will give the error message.– rray
On the external host you need to give root user access or create a certificate. Here has a similar question.
– rray