连接失败mysqli php

时间:2017-04-27 12:16:08

标签: php mysql

我在PHP中设置了与mysql服务器(OVH)的连接,如下所示:

$con = mysqli_connect("myserver.mysql.db","user","pass","bdd") or die("Couldn't connect");

它无法连接它,说主持人不知道。但这是我对服务器的唯一信息

我该怎么做才能克服这个问题?

谢谢

编辑:

这是php代码:

class dbconnection{
    function connect(){
        $con = mysqli_connect("myserv.mysql.db","user","mdp","bdd") or die("Couldn't connect" .  $con->connect_error);
        return $con;
    }
}

然后:

$con = new dbconnection();
$db = $con -> connect();

以下是错误消息:

Warning: mysqli_connect(): php_network_getaddresses: getaddrinfo failed: unknown host. in C:\xampp\htdocs\hackaton\class\dbconnection.php on line 11

Warning: mysqli_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: unknown host. in C:\xampp\htdocs\hackaton\class\dbconnection.php on line 11

Notice: Trying to get property of non-object in C:\xampp\htdocs\hackaton\class\dbconnection.php on line 11
Couldn't connect

0 个答案:

没有答案