Skip to content

Instantly share code, notes, and snippets.

@Mattia541993
Created May 25, 2020 15:43
Show Gist options
  • Save Mattia541993/6969b5c8f002d736382bb2fcc278d899 to your computer and use it in GitHub Desktop.
Save Mattia541993/6969b5c8f002d736382bb2fcc278d899 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php
$servername = "database";
$username = "root";
$password = "123";
$dbname = "stt_db";
$port = "3306";
try{
$conn = new PDO("mysql:host=$servername;port=$port;dbname=$dbname",$username,$password);
$conn -> setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
echo "Connected succesfully";
} catch(PDOException $e){
echo "Connection failed: " . $e -> getMessage();
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment