Results 1 to 1 of 1
  1. #1
    Join Date
    Apr 2003
    Posts
    142

    Unanswered: SQLSTATE[HY000] [2002] Connection timed out

    Hi,

    I keep getting above error when trying to connect from PHP but I am able to connect using the same credentials from Navicat.

    This is the error:

    <br />
    <b>Fatal error</b>: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] Connection timed out' in /home/meskholdings/mydomain.com/ws/verify_customer_app_id2.php:21
    Stack trace:
    #0 /home/meskholdings/mydomain.com/ws/verify_customer_app_id2.php(21): PDO-&gt;__construct('mysql:host=88.2...', 'root', 'xxxxxx', Array)
    #1 {main}
    thrown in <b>/home/meskholdings/mydomain.com/ws/verify_customer_app_id2.php</b> on line <b>21</b><br />


    and this is my PHP:

    header("Content-Type: application/json");

    if (isset($_SERVER['HTTP_ORIGIN'])) {
    header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
    header('Access-Control-Allow-Credentials: true');
    header('Access-Control-Max-Age: 86400'); // cache for 1 day
    }

    $classification = $_POST["cl"];

    $mysql_host = "mysql:host=xxx.xxx.xxx.xxx;port=3366;dbname=savan na";
    $mysql_user = "root";
    $mysql_password = "xxxx;
    $mysql_options = array
    (
    PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
    );

    // $mysql_connection;
    $mysql_connection = new PDO($mysql_host, $mysql_user, $mysql_password, $mysql_options);
    $mysql_connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);


    Kindly help


    Thanks,
    Jassim
    Last edited by jrahma; 05-12-17 at 21:49.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •