Shruti
Shruti

Reputation: 41

Warning: mysqli::__construct(): (HY000/1045): ProxySQL Error: Access denied for user 'root'@'2a02:4780:bad:f00d::18' (using password: NO) on line 12

I have created a basic page with php and MySQL, but somehow i seem to be getting this error. I Have tried entering my MySQL server password but it shows the same error anyway. I am hosting this page from 000webhost and i have just been introduced to coding.

 <?php
    $username= filter_input(INPUT_POST,'username');
    $password= filter_input(INPUT_POST,'password');
    if (!empty($username)) {
        if (!empty($password)) {
            $host = "localhost";
            $dbusername = "root";
            $dbpassword = "";
            $dbname = "project";

            //create connection
    $conn = new mysqli($host, $dbusername, $dbpassword, $dbname);

    //check connection
    if(!$conn)
    {
     die("connection failed: ". mysqli_connect_errno());
     }
     else{
     echo "Connected successfully";
      }

        }
        else{
            echo "password should not be empty";
            die();
        }

        }
    ?>

Upvotes: 4

Views: 21348

Answers (4)

Aan B
Aan B

Reputation: 1

If you use 000webhost, just change the database password in the database manager menu until the connection is successful. This is usually because the password contains prohibited characters.

Upvotes: 0

Purushotam Sah
Purushotam Sah

Reputation: 96

Make sure you are using correct value for $host, $dbusername, $dbname, $dbpassword from the database you want to connect. Please refer to the image below:

enter image description here

Upvotes: 0

Shany
Shany

Reputation: 13

Make your database in Database Manager first (in 000webhost). Then, change your $dbusername, $dbpassword, and $dbname as provided by 000webhost.

Upvotes: 1

Kathir
Kathir

Reputation: 21

Follow these steps:

  1. Make sure database password not contain * special character.
  2. Make sure your database name and database username are correct.
  3. Delete all files from /bootstrap/cache except .gitignore.

Upvotes: 1

Related Questions