0
  • There has been other questions but they are all outdated
define('DBUSER', 'Pho');
define('DBPASS', 'pass');
define('DBSERVER', 'chides');
define('DBNAME', 'partstest1');

$conn = new mysqli(DBSERVER, DBUSER, DBPASS, DBNAME);

if (!$conn) {
    die('error connecting to database');
}

echo 'connection!';
?>

This throws up the error: [Warning: mysqli::__construct(): php_network_getaddresses: getaddrinfo failed: No such host is known. in D:\xampp\htdocs\Form\phpmk1.php on line 7

Warning: mysqli::__construct(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: No such host is known. in D:\xampp\htdocs\Form\phpmk1.php line 7

I am aware that php 7 no longer uses the mysql_ commands is there a work around for this? I am also going to be using this to take data from a local webform to then place inside the database shown I was told sqli would work but im not sure if i am doing it right

Any help would be greatly appreciated. Thanks

PhoChiDes
  • 23
  • 1
  • 7
  • DBSERVER is the problem. Try using an ip address instead of `chides` – ryantxr Feb 25 '20 at 21:58
  • is chides a valid hostname ? try **ping chides** from a CMD window – Bernd Buffen Feb 25 '20 at 21:58
  • Changing to the ip address removed the bottom error - Thanks :) – PhoChiDes Feb 25 '20 at 22:00
  • 1
    @PhoChiDes actually reading the error messages goes a long way... this is basic debugging: first it clearly said the host wasn't right, now it's clearly saying that the credentials aren't right. Try to read the error before copypasting it to SO. – mrodo Feb 25 '20 at 22:07
  • 3
    Turning this into a [chameleon question](https://meta.stackoverflow.com/questions/332820/what-to-do-when-someone-answers-dont-be-a-chameleon-dont-be) doesn't make it exactly more useful than the thousands of previous questions. It just adds to the pile with no benefit to others. – mario Feb 25 '20 at 22:09
  • Will do next time. Sorry for wasting your time. Thanks for all the help though :) – PhoChiDes Feb 25 '20 at 22:11
  • I just don't really know how to use this platform yet – PhoChiDes Feb 25 '20 at 22:13

1 Answers1

-1

The error clearly shows that mysqli cannot connect to the host. mysqli itself is not the issue here, what you are defining as DBSERVER is. You have to specify a valid host, and chides isn't.

mrodo
  • 565
  • 5
  • 21
  • Thanks just changed to the ip address to the bottom error is now longer the issue will edit to show the new problem. :) – PhoChiDes Feb 25 '20 at 22:03