skip to Main Content

I am trying to establish a connection between my android app and an online host, however, I am getting the following error in the cpanel’s error_log:

[27-Feb-2017 14:19:14 Etc/GMT] PHP Warning:  mysqli_connect(): (28000/1045): Access denied for user 'whiteweb_root'@'209.99.16.16' (using password: YES) in /home/whiteweb/public_html/conn.php on line 6

Here is conn.php:

<?php
$host = "209.99.16.16";
$mysql_username = "whiteweb_root";
$mysql_pwd = "123456";
$db_name = "whiteweb_deliverus";
$conn = mysqli_connect($host, $mysql_username, $mysql_pwd, $db_name);
?>

The error seems to occur as I try to establish a connection using mysqli_connect but I believe I have written it properly. All the arguments for mysqli_connect are correct and I have assigned the user to the database in the cpanel and given the user all privileges. Additionally, the code in my android application is correct and it worked perfectly using wampserver.

I have tried looking for a solution online to no avail. Any help on how to fix the problem will be highly appreciated. Thanks

2

Answers


  1. Most probably your setting on cPanel is wrong. Have you given remote access to that user? If not do so and all will be good. 🙂

    Login or Signup to reply.
  2. it looks that your configuration for mysql access is restricted to localhost aka 127.0.0.1

    this line

    $host = "209.99.16.16";
    

    tries to connect to the database but it will behave (at least for Mysql server) as if it was a remote connection.
    if your code (php) and db server are located on the same machine, then use this host instead

    $host = "127.0.0.1"; // or localhost
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search