简体   繁体   English

PHP连接到MySQL数据库

[英]php connection to mysql database

I have a website (www.calendariocubano.org) hosted in Godaddy.com, and I have a mysql database server at home. 我在Godaddy.com上托管了一个网站(www.calendariocubano.org),并且我在家中有一个mysql数据库服务器。

I would like to make all the registration process in my database home server, but I can't make the connection. 我想在数据库主服务器中完成所有注册过程,但是无法建立连接。

Below is the function used to connect. 以下是用于连接的功能。 Before put the database at home, I have it at Goddady and it works. 在将数据库放在家里之前,我先将它放在Goddady上,然后它可以工作。

function doDB() {
    global $mysqli;
    $mysqli = mysqli_connect("50.250.86.124","admin","xxxxxxxxxxxx","calendariocubano"); 
    if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit();
    }
}

Having some component at your home pegs the website availability to your home server availability. 家庭中有一些组件会将网站可用性与家庭服务器可用性挂钩。 I wouldn't recommend it. 我不推荐它。

But the most likely reason why you can't connect is, your home router may be blocking the mysql port. 但是最可能无法连接的原因是,家用路由器可能阻塞了mysql端口。 Go to the firewall settings on your router and allow mysql port(default usually is 3306) and see if that changes anything. 转到路由器上的防火墙设置,并允许mysql端口(默认通常为3306),然后查看是否会更改任何内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM