0

php code which is functioning very well in my computer but whenever i am uploading my files to my Cpanel not working receiving this error message:

Warning: mysqli::mysqli() [mysqli.mysqli]: (42000/1044): Access denied for user '*****'@'localhost' to database '*****' in /home/*****/public_html/Admin Panel/db.php on line 3 Unable to connect to database [Access denied for user '*****'@'localhost' to database '*****']

My username and password both are 100% correct but i don't know why i am receiving this.

<?php
    $connection=new mysqli('localhost', 'CpanelName_username', 'test.123', 'CpanelName_DB');
    if($connection->connect_errno > 0){
        die('Unable to connect to database [' . $connection->connect_error . ']');
    }
?>
Falko
  • 17,076
  • 13
  • 60
  • 105
Shah Jeee
  • 29
  • 1
  • 6

1 Answers1

1

Check if localhost should be used.

Many shared hosting providers may not have database on the same machine. So check the database hostname and change accordingly.

Pruthvi Raj Nadimpalli
  • 1,335
  • 1
  • 15
  • 30