2

When I'm using XAMPP localhost my system is working but when I upload it in cpanel other page not working. other page is working like login but in view and edit page it gets error.

I got this error:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1044] Access denied for 

other page:

Connection failed: SQLSTATE[HY000] [1044] Access denied for 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 I changed the connection approach

<?php
mysql_connect("localhost", "xx", "xx") or die(mysql_error());
mysql_select_db("xx") or die(mysql_error());
?>

I got this error:

Fatal error: Call to a member function prepare() on a non-object in 
kim de castro
  • 299
  • 6
  • 19

1 Answers1

0

Access denied: your credentials are wrong: different with your localhost!

Are you sure they're correct:

  • use 127.0.0.1 instead of localhost, or try another specific server name or ip
  • make sure that your password doesn't contain a $ character, or between single quotes
schellingerht
  • 5,726
  • 2
  • 28
  • 56
  • If I'm using localhost(xampp) its working. but when I upload it I'm getting that error on other pages. btw I tried your advice but still doesnt work. – kim de castro Aug 25 '15 at 04:43