Skip to content

Instantly share code, notes, and snippets.

@Rameshwar-ghodke
Created March 30, 2017 11:58
Show Gist options
  • Save Rameshwar-ghodke/6b506c3e3299a39d0bb39fa0a2be312c to your computer and use it in GitHub Desktop.
Save Rameshwar-ghodke/6b506c3e3299a39d0bb39fa0a2be312c to your computer and use it in GitHub Desktop.
<?php
$servername = "localhost";
$username = "username";
$password = "password";
try {
$conn = new PDO("mysql:host=$servername;dbname=myDB", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment