Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = '127.0.0.1';
- $username = 'dbuser';
- $password = 'dbpassword';
- $dbname = 'dbname';
- // Create connection
- $conn = new mysqli($servername, $username, $password);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- echo "Connected successfully";
- echo "\nTest PDO\n";
- try {
- $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
- // set the PDO error mode to exception
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- echo "PDO Connected successfully";
- } catch(PDOException $e) {
- echo "PDO Connection failed: " . $e->getMessage();
- }
Add Comment
Please, Sign In to add comment