mysql - PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1045] Access denied for user -


i have made project in php oop , runs perfect @ localhost server tried uploading site online server , made database user , connect db project this:

 <?php  class connection {     public function dbconnect()     {         return new pdo("mysql:host=127.0.0.1; dbname=danoupco_host", "za{c?quyq8g", "danoupco_user");     } } ?> 

everything looks fine problem not load site. , error message on browser:

this page isn’t working

your site unable handle request.

http error 500

so saw error_log , says:

[10-sep-2017 13:53:02 utc] php fatal error: uncaught exception 'pdoexception' message 'sqlstate[hy000] [1045] access denied user 'za{c?quyq8g'@'localhost' (using password: yes)' in db.class.php line 6

so here line 6 of db.class.php:

return new pdo("mysql:host=127.0.0.1; dbname=danoupco_host", "za{c?quyq8g", "danoupco_user"); 

and checked mysql database name , user , correct:

print screen

so don't know whats going on there... can check site , see yourself.

share|improve question
up vote 1 down vote accepted

you have username , password parameters reversed.

share|improve answer
    
what u mean that – ciomaejobaep sep 10 @ 16:16
    
instead of pdo("mysql:host=127.0.0.1; dbname=danoupco_host", "za{c?quyq8g", "danoupco_user"); should have pdo("mysql:host=127.0.0.1; dbname=danoupco_host", "danoupco_user", "za{c?quyq8g"); – jjones sep 10 @ 16:22

your answer

 
discard

posting answer, agree privacy policy , terms of service.

not answer you're looking for? browse other questions tagged or ask own question.

Comments