0

here is my code :

<?php
$servername = "XXXXXXXXX";
$username = "XXXXXXXX";
$password = "XXXXXXXXX";

$conn = mysqli_connect($servername, $username, $password);

// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
?>

and here is the error

Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'rgwyatt_loganf'@'192.185.46.82' (using password: YES) in /home4/rgwyatt/public_html/loganf/test.php on line 14 Connection failed: Access denied for user 'rgwyatt_loganf'@'192.185.46.82' (using password: YES)

Scuzzy
  • 12,186
  • 1
  • 46
  • 46

1 Answers1

1

It is probably a permissions problem. Double check that the ip, user name and password (if required) are correct. If you are trying to connect from a different ip, maybe you don't have permission for your ip.

Also notice that the error you have posted gives away the ip user name and password.

And if you are trying to connect to a specific DB, then you are missing the db parameter.

It should be like this:

$con=mysqli_connect($servename,$username,$password,$db);
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
matisa
  • 497
  • 3
  • 25
  • It's actually optional. The db argument is only required if querying a database table. One can still successfully connect without it. One would get something back like this: *"Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in on line x"*. This when using that function to query with as an example. – Funk Forty Niner Aug 21 '17 at 23:08
  • Tnx for your comment. You are correct. I edited the response already. – matisa Aug 21 '17 at 23:24