(protocol / network address / port) [closed]

-4

When I use the setInterval(getFollow(), 60000); function (1 minute or more or less always the same problem) of javascript I get this error from the PDO:

  

SQLSTATE [HY000] [2002] Usually only one use is allowed   of each socket address (protocol / network address / port).

I searched the web here, and found nothing.

Why are you giving this?

I need to update the wait minutes count for a new action.

    
asked by anonymous 14.08.2018 / 17:11

1 answer

1

Without your PDO we can not know what you did wrong, since the error is in it, but anyway you can say that this SQLSTATE[HY000] [2002] message indicates that you configured something wrong in this:

'mysql:dbname=testdb;host=mysql.host_de_exemplo.com'

For example:

$dsn = 'mysql:dbname=testdb;host=mysql.host_de_exemplo.com';
$user = 'dbuser';
$password = 'dbpass';

try {
    $dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();
}
  • Or you did not properly set $dsn , leaving it empty
  • Or host= you pointed does not exist
  • Or host= is empty
  • Or you put a wrong port, for example:

    $dsn = 'mysql:dbname=testdb;host=mysql.host_de_exemplo.com:8000';
    
      

    Usually the default port is 3306

  • Or you're running this script on an online server and not on your machine, but you're still trying to access the localhost domain, like this:

    $dsn = 'mysql:dbname=testdb;host=localhost';
    

Only in online servers rarely mysql server is at the same address of the http server, ie it does not have access via localhost, it is necessary to point the correct address that the host tells you, usually it is only the IP code, usually is informed in your panel (like cpanel or something similar), example:

$dsn = 'mysql:dbname=testdb;host=169.3.23.1';
    
14.08.2018 / 17:21