我正在创建一个网页。网页有一个表单,表单数据通过.php
页面发送,保存在MySQL数据库中。我正在使用XAMPP
这是我的剧本:
$dbc = mysqli_connect('http://localhost:8080/127.0.0.1','root',' ','aliendatabase');
$query = "INSERT INTO aliens_abduction (first_name,last_name,when_it_happened, how_long, " .
"how_many, alien_description, what_they_did, fang_spotted, other, email) " .
"VALUES ('Nadreen', 'Muhammad Ali', 'since birth', '21 years', 'all of them', 'sad cretures', " .
"'ruined me', 'yes', 'I may have seen your dog. Contact me.', " .
"'sally@gregs-list.net')";
$result = mysqli_query($dbc,$query)
or die('Error querying database.');
mysqli_close($dbc);
我一直在收到这些错误:
Warning: mysqli_connect(): php_network_getaddresses: getaddrinfo failed:
The requested name is valid, but no data of the requested type was found
和
mysqli_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed:
The requested name is valid, but no data of the requested type was found
答案 0 :(得分:0)
而不是:
$dbc = mysqli_connect('http://localhost:8080/127.0.0.1','root',' ','aliendatabase');
使用此:
$dbc = mysqli_connect('localhost','root','','aliendatabase');