Hi Guys,
I have a 2 errors with PDO:
Sometimes give me this error:
Connection error, because: SQLSTATE[HY000] [2013] Lost connection to MySQL server at 'reading initial communication packet', system error: 111

Other time sent me this:
SQLSTATE[42000] [1203] User [MYUSERNAME] already has more than 'max_user_connections' active connections

This is my connect to database script:

try{
  $db = new PDO("mysql:host=mysqlwebhost;dbname=databsename",$dbuser,$dbpass);
}
catch(PDOException $e){
  die('Connection error, because: ' .$e->getMessage());
}

Where can I read more about errors and how to defeat them?

Recommended Answers

mysql:host=mysqlwebhost

try

mysql:host=localhost

If that's an option for you.

Jump to Post

All 2 Replies

Member Avatar

mysql:host=mysqlwebhost

try

mysql:host=localhost

If that's an option for you.

@ardav, I changed it to something because I don't want to ads hosts. Connection is successful, but sometimes makes errors. Thanks you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.