mysql_connect 不适用于站点

mysql_connect 不适用于站点

问题描述:

所以我在本地完成了一个站点,并且我一直在尝试将其传输到在线服务器.这可能是一个非常愚蠢的问题,但我花了最后一个小时试图找到答案,但我找不到.所以这是在服务器上运行的一行 PHP 代码(用户名和密码已更改,但主机名相同):

so I finished a site locally, and I have been trying to start to transfer it to an online server. And this is probably a really stupid question but I've spent the last hour trying to find the answer and I can't. So this is a line of PHP code being run on the server (with the username and password changed, but the hostname the same):

if(!mysql_connect("www.bluestreakaquatic.com","username","password"))
die(mysql_error());

它产生这个错误:

Can't connect to MySQL server on 'www.bluestreakaquatic.com' (10061)

谁能给我一些建议?

出于安全原因,您的托管服务提供商可能不允许外部 mySQL 连接.

Your hosting provider probably doesn't allow external mySQL connections for security reasons.

如果 mySQL 与您的站点在同一台服务器上运行,请尝试将域名替换为 localhost.

If mySQL runs on the same server as your site, try replacing the domain name with localhost.

如果这不起作用,您需要向您的托管服务提供商询问正确的数据库服务器地址.

If that doesn't work, you need to ask your hosting provider for the correct database server address.