简体   繁体   中英

Can't connect to the database out of the local host

I've been trying to connect to database using this .php code: My number port is 2086. The following code woks using the localhost bu not when I tried to run out of the localhost (on the live site). There is only write "error" that strange that mysqli_connect_error() function doesn't return anything. Can I find a solution ?

<?php

  if ($enlace = mysqli_connect("ip+port", "username", "password", "databases"))
        echo 'connect to the databases';
  else
    {
      printf("error", mysqli_connect_error());
      exit();
    }
?>

This:

$enlace = mysqli_connect("ip+port", etc...
                            ^^^^^

is incorrect. port is specified as argument #5:

$enlace = mysqli_connect($hostname, $username, $password, $dbname, $port)
                                                                   ^^^^^

It finally work !! I changed the domain name of the site and it's works. I think the problem is due to the old domain name. I'm sent them a mail for try to find a solution.

thank you for all of you help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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