php - Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1044] When I uploaded it online -
this question has answer here:
when i'm using xampp localhost system working when upload in cpanel other page not working. other page working login in view , edit page gets error.
i got error:
fatal error: uncaught exception 'pdoexception' message 'sqlstate[hy000] [1044] access denied
other page:
connection failed: sqlstate[hy000] [1044] access denied user
my connection:
<?php $db_host = 'localhost'; $db_user = 'xxx'; $db_pass = 'xxx'; $db_database = 'xxx'; $db = new pdo('mysql:host='.$db_host.';dbname='.$db_database, $db_user, $db_pass); $db->setattribute(pdo::attr_errmode, pdo::errmode_exception); ?>
if changed connection approach
<?php mysql_connect("localhost", "xx", "xx") or die(mysql_error()); mysql_select_db("xx") or die(mysql_error()); ?>
i got error:
fatal error: call member function prepare() on non-object in
access denied: credentials wrong: different localhost!
are sure they're correct:
- use 127.0.0.1 instead of localhost, or try specific server name or ip
- make sure password doesn't contain $ character, or between single quotes
Comments
Post a Comment