Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/02/2023 in all areas

  1. Why do you think it wouldn't work for other errors? It says in the manual It doesn't say it throws on invalid username/password, it says it throws on failure. Invalid username / password is only one of many reasons why the connection attempt might fail.
    1 point
  2. <?php $host = 'localhost'; // your database host $dbname = 'mydatabase'; // your database name $username = 'myusername'; // your database username $password = 'mypassword'; // your database password try { $pdo = new PDO("mysql:host=$host;dbname=$dbname", $username, $password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // set additional PDO attributes if needed } catch (PDOException $e) { echo 'Connection failed: ' . $e->getMessage(); } ?>
    1 point
This leaderboard is set to New York/GMT-04:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.