1

I tried using the following code in php:

<?php
$servername = "www.psgcirdask.com";
$username = "xxx"; //hidden for security purpose
$password = "password";
$dbname = "psgcilqh_calibration";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
 // Check connection
  if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

  $sql = "SELECT * FROM brands";
  $result = $conn->query($sql);
$conn->close();
?>

I got an error:

Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'xxx'@'157.51.147.43' (using password: YES) in C:\xampp\htdocs\justshawarmapos\checkthedatabase.php on line 9 Connection failed: Access denied for user 'xxx'@'157.51.147.43' (using password: YES)

But i use the same username and password to connect to my database in my website.I am getting this problem only when i connect using local server.

tk3
  • 990
  • 1
  • 13
  • 18

2 Answers2

1

You have to enable remote access in your mysql database.

Check this link

For hostgator

Gabriel
  • 970
  • 7
  • 20
0

Check if all the infos provided are correct especially the servername then try to figure out if you have the right permission to access that database with that user!