我正在使用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.
出现在页面上。为什么会这样,我该如何解决它呢?
答案 0 :(得分:4)
您必须指定MySQL实例的主机名而不是phpMyAdmin的URL。
更改
... mysqli("http://localhost/us_phpmyadmin/","","","url_short");
到
... mysqli("localhost", "", "", "url_short");
^^^^^^^^^