Skip to content

Instantly share code, notes, and snippets.

@tararoutray
Created January 13, 2022 17:46
Show Gist options
  • Save tararoutray/2c850d1d8882d10b2d18d4d6541036d9 to your computer and use it in GitHub Desktop.
Save tararoutray/2c850d1d8882d10b2d18d4d6541036d9 to your computer and use it in GitHub Desktop.
<?php
/*
* Connect to the MySQL server.
*/
try {
/*
* Provide the database credentials.
*/
$pdo = new PDO("mysql:host=192.x.x.x;dbname=mydatabase", "tararoutray", "mystrongpassword");
/*
* Print the success message.
*/
echo 'Database connection has been established';
} catch(PDOException $e) {
/*
* Print the error message.
*/
die("ERROR: Could not connect. " . $e->getMessage());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment