mysqli_connect():(HY000/2003):无法连接到“域名"上的MySQL服务器(111) [英] mysqli_connect(): (HY000/2003): Can't connect to MySQL server on 'domain name' (111)
问题描述
我对php和SQL还是很陌生,并且在连接到我的SQL数据库时遇到问题.我提交HTML表单时收到以下错误.
Im very new to php and my SQL, and am having trouble connecting to my SQL Database. Im getting the following error when i submit my HTML Form.
mysqli_connect(): (HY000/2003): Can't connect to MySQL server on 'domain name' (111)
这是我的php代码:
<?
$name=$_POST['name'];
$email=$_POST['email'];
$location=$_POST['location'];
mysqli_connect("domain_name", "1645347_data", "*password omitted*") or die(mysql_error()); //error getting thrown at this line
mysqli_select_db("1645347_data") or die(mysql_error());
mysqli_query("INSERT INTO `data` VALUES ('$name', '$email', '$location')");
Print "Your information has been successfully added to the database.";
?>
如您所见,这是一个非常简单的php脚本(正如我正在学习的教程一样).
As you can see, it is a very simple php script (as I am following a tutorial).
有人可以看到我为什么会得到这个错误吗?我非常乐意根据要求提供其他信息.
Can anybody see why i would be getting this error? im more than happy to provide additional information if requested.
推荐答案
您的脚本似乎正在尝试连接域名",但由于该服务器未在DNS上列出,因此找不到该服务器.您的服务器是否在同一台计算机上?因此,您需要使用localhost,127.0.0.1或服务器的IP替换domain_name.
It looks like your script is trying to connect "domain_name", but it can't find that server because it's not listed on the DNS's. Is your server on the same machine? In that cause you need to replace domain_name with localhost, 127.0.0.1 or the ip of the server.
在运行SQL命令之前,还必须确保对输入进行消毒!!!
这篇关于mysqli_connect():(HY000/2003):无法连接到“域名"上的MySQL服务器(111)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!