Localhost php_network_getaddresses:getaddrinfo failed:没有这样的主机

时间:2013-10-09 08:37:20

标签: php mysql apache mysqli

我正在使用Localhost和UniServer,运行Apache和MySQL。 (没有用户名或密码)
我有代码new mysqli("http://localhost/us_phpmyadmin/","","","url_short");来连接到我的Localhost服务器,但是当我尝试运行代码mysqli_query("INSERT INTO cut.it VALUES (NULL, $longurl, $shorturl)");时 ,错误php_network_getaddresses: getaddrinfo failed: No such host is known.出现在页面上。为什么会这样,我该如何解决它呢?

1 个答案:

答案 0 :(得分:4)

您必须指定MySQL实例的主机名而不是phpMyAdmin的URL。

更改

... mysqli("http://localhost/us_phpmyadmin/","","","url_short");

... mysqli("localhost", "", "", "url_short");
            ^^^^^^^^^