I'm just doing a tutorial, learning PHP/mySQL for the first time, and have been having problems getting PHP to talk to mySQL, so to speak.
The tutorial is from here:
Here is the code:
<?php
$link = mysql_connect('http://192.168.0.8:3307', 'ddd1600', '');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
// make foo the current db
$db_selected = mysql_select_db('test', $link);
if (!$db_selected) {
die ('Could not connect: ' . mysql_error());
}else{
echo "It worked!";
}
$sql =
"INSERT INTO `test`.`Table2` (
`ID` ,
`name` ,
`content`
)
VALUES (
NULL , 'apples', 'are grown by Australians.');"
; ?>
My server is on my private network, by the way.
Thanks!
PS:
If it helps, here is the error message from Chrome browser or any other browser:
Warning: mysql_connect() [function.mysql-connect]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\xampp\htdocs\PhpProject1\index.php on line 4
Warning: mysql_connect() [function.mysql-connect]: [2002] php_network_getaddresses: getaddrinfo failed: No such host is known. (trying to connect via tcp://http:3306) in C:\xampp\htdocs\PhpProject1\index.php on line 4
Warning: mysql_connect() [function.mysql-connect]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\xampp\htdocs\PhpProject1\index.php on line 4
Could not connect: php_network_getaddresses: getaddrinfo failed: No such host is known.