Answers for "php pdo database connection class example"

PHP
8

php pdo connection

$host     = "localhost";//Ip of database, in this case my host machine    
$user     = "root";	//Username to use
$pass     = "qwerty";//Password for that user
$dbname   = "DB";//Name of the database

try {
    $connection = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
    $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

}catch(PDOException $e)
{
  echo $e->getMessage();                         
}
Posted by: Guest on April-14-2020
0

php pdo sql server connect

$db = new PDO("sqlsrv:Server=YouAddress;Database=YourDatabase", "Username", "Password");
Posted by: Guest on February-05-2020

Code answers related to "php pdo database connection class example"

Browse Popular Code Answers by Language