Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

pdo connection

<?php
$servername = "localhost";
$username = "root";
$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();
}
?>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pdo #connection
ADD COMMENT
Topic
Name
3+2 =