2

This is the error I'm getting

PHP Warning: mysqli::__construct(): (HY000/1130): Host 'ip98-436-9-183.dc.dc.cox.net' is not allowed to connect to this MySQL server in /home/ahmadarsalann/php/edit.php on line 7 Connection failed: Host 'ip72-205-1-229.dc.dc.cox.net' is not allowed to connect to this MySQL server

Down below is the code I'm using

<?php
$servername = "umw3.reclaimhosting.com";
$username = "username";
$password = "password";

// Create connection
 $conn = new mysqli($servername, $username, $password);

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

I'm using wordpress, and I'm trying to connect to the backend of the database in the code to edit data on there. The password and username isn't real for security reasons. But so far this is what I got to connect to the database using php, because that's the language it's using.

The database is in the php my admin I'm trying to access wp post. It is in php myAdmin, wp post is used by wordpress.

The picture of the info needed here :

enter image description here

Dharman
  • 30,962
  • 25
  • 85
  • 135
Ben Curch
  • 21
  • 3
  • It looks like your user is not permitted to connect from your source IP. What is the `host` of your user, you can get this by querying: `select host, user from mysql.user where user = '{insert username}';` – Dylan Reimerink Nov 15 '21 at 18:47
  • @caveman i tried that and then i got an error saying "SELECT comand denied to user 'umw' for table 'user' " I apologize for not being well known in this, this is not my usual field. – Ben Curch Nov 15 '21 at 18:55
  • Ah, your user doesn't have permission to access the mysql.user table, use the root/admin user if you have access to it. If you're not, you should ask the db admin for this info. He will likely also be able to fix the issue for you. In case you are the db admin, when creating an user you have to specify a host like `CREATE USER 'jeffrey'@'localhost'`. If you set host to % you will be able to connect from any source IP(which is a security risk). `CREATE USER 'jeffrey'@'%'` – Dylan Reimerink Nov 15 '21 at 19:20
  • Are you by coincidence trying to connect from your local computer? – lukas.j Nov 15 '21 at 20:29
  • @lukas.j indeed i am – Ben Curch Nov 15 '21 at 20:37
  • 1
    This is usually prohibited by web hosters for security reasons. So while developing and testing on your computer you need to run a web server and a mysql database locally. – lukas.j Nov 15 '21 at 20:38
  • Is there a way to bypass that, it is my own website on wordpress. I'm using Domain's of one own – Ben Curch Nov 15 '21 at 21:07

0 Answers0