0

I have host on 000webhost when i will try to connect it gives me this error i cannot figure out whats the problem ?
Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/1130): Host '31.170.161.176' is not allowed to connect to this MySQL server in /home/a2548020/public_html/includes/connection.php on line 6

here is my connection script

<?php
    $DBServer = ''; //my info
    $DBUser   = ''; //my info
    $DBPass   = ''; //my info
    $DBName   = ''; //my info
    $conn = new mysqli($DBServer, $DBUser, $DBPass, $DBName);
    //$conn = mysqli_connect($DBServer, $DBUser, $DBPass, $DBName);

    if (!$conn) {
        die("Connection failed: " . mysqli_connect_error());
    }
?>

Edited by Stefan_1

3
Contributors
8
Replies
30
Views
1 Year
Discussion Span
Last Post by Stefan_1
0

Sorry i didnt get you can you explain me more how should i do that ? sorry i dont have to much knowledge in PHP

0

Basically what I'm trying to determine is whether you can connect at all. I assume you have a way of viewing your DB info, perhaps phpMyAdmin? You may have to review the user privileges.

Edited by RudyM: Added info.

1

Hi, supposing 31.170.161.176 was your IP address, you cannot connect directly from your computer to the 000webhost MySQL server because remote connection is disabled, unless you upgrade your account:

It means that, with the basic plan, they only allow connections to the databases from a defined range of IPs: their hosting machines. So in order to work, you have to upload the script to the 000webhost web server and run it from there, not from your local installation.

Edited by cereal

0

I putted the script files into their File Manager in public_html also there was 2 files one default.php and the other i dont remember, i have deleted them and placed my files there. Maybe its because of them ? Also i had on the same server other files and it was working good.. so now when im uploading this new files that error appear. So i need to pay for my account to use 000webhost ?

1

i have deleted them and placed my files there. Maybe its because of them ?

This should not affect the execution of your scripts or the connection, in general, to the database.

So i need to pay for my account to use 000webhost ?

No, unless you want to connect directly to the database from another host (i.e. localhost, or another web hosting service).

Also i had on the same server other files and it was working good.. so now when im uploading this new files that error appear.

This confuses me: the error reported in your first post returns a Macedonian IP address, which means the attempt connection was executed from a script in a computer in Macedonia, not from a 000webhost machine.

If $DBServer is a 000webhost database and the scripts are executed in a 000webhost hosting then, you may want to ask help to their support or to their forums.

1

Thank you cereal! Finally realized that i was using wrong $DBServer info :S

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.