[英]Warning: mysqli::__construct(): (HY000/2002): Connection refused in
I am trying to do some coding and I've taken a free webhost for that.我正在尝试进行一些编码,为此我使用了免费的虚拟主机。
$servername = "127.0.0.1";
$username = "ltm_23041946";
$password = "pass_wass_heree";
$dbname = "ltm_23041946_a";
$conn = new mysqli($servername, $username, $password, $dbname);
Is my code, but I get multiple errors with this.是我的代码,但是我遇到了多个错误。 Here are my errors;这是我的错误;
Warning: mysqli::__construct(): (HY000/2002): Connection refused in >/home/vol14_2/ultimatefreehost.in/ltm_23041946/htdocs/create.php on line 12警告: mysqli::__construct(): (HY000/2002): Connection denied in >/home/vol14_2/ultimatefreehost.in/ltm_23041946/htdocs/create.php on line 12
Notice: Undefined variable: conn in >/home/vol14_2/ultimatefreehost.in/ltm_23041946/htdocs/create.php on line 18注意:未定义变量:conn in >/home/vol14_2/ultimatefreehost.in/ltm_23041946/htdocs/create.php on line 18
Fatal error: Uncaught Error: Call to a member function query() on null in >/home/vol14_2/ultimatefreehost.in/ltm_23041946/htdocs/create.php:18 Stack >trace: #0 /home/vol14_2/ultimatefreehost.in/ltm_23041946/htdocs/create.php(51): >insert('a', 'md2') #1 {main} thrown in >/home/vol14_2/ultimatefreehost.in/ltm_23041946/htdocs/create.php on line 18致命错误:未捕获的错误:在 >/home/vol14_2/ultimatefreehost.in/ltm_23041946/htdocs/create.php:18 中的 null 上调用成员函数 query() 堆栈 >trace: #0 /home/vol14_2/ultimatefreehost.in /ltm_23041946/htdocs/create.php(51): >insert('a', 'md2') #1 {main} 在第 18 行抛出 >/home/vol14_2/ultimatefreehost.in/ltm_23041946/htdocs/create.php
I searched around trying to get answers, but I am still stuck with this.我四处寻找答案,但我仍然坚持这一点。 If anyone could help, I would be thankfull!如果有人可以提供帮助,我将不胜感激!
Even using 127.0.0.1
connection might not work in servers with multiple interfaces or with special routing rules.即使使用127.0.0.1
连接也可能不适用于具有多个接口或具有特殊路由规则的服务器。 Run mysqlcheck --help
and take the IP address and port shown at the bottom in the "port" and "host" fields.运行mysqlcheck --help
并获取显示在“端口”和“主机”字段底部的 IP 地址和端口。 For example:例如:
port 3306
host 192.168.1.23
Use the IP and port that MySQL recognizes:使用 MySQL 识别的 IP 和端口:
$servername = "192.168.1.23:3306";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.