Server2Go PDO error connection

Posted: October 20, 2010 in Php, Uncategorized

Server2Go PDO error connection

Error message:

Warning: PDO::__construct() [pdo.–construct]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in on line #
Fatal error: Maximum execution time of 60 seconds exceeded in on line #

Solution:
Change the ‘localhost’ to 127.0.0.1

$dsn = “mysql:host=127.0.0.1;port=$S2G_MYSQL_PORT;dbname=haulagemy”;
$username = “root”;
$password = “”;

try {
           $dbh = new PDO($dsn, $username, $password);
           $dbh->active=true;
           foreach ($dbh->query(‘SELECT * from tbl_users’) as $row) {
              print_r($row);
           }
           $dbh = null;
        } catch (PDOException $e) {
           print “Error!: ” . $e->getMessage() . “
“;
           die();
        }

View here for more details –> tinsology.net

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s