Answers for "what is pdo connection"

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

PDO connect

<?php
$db = new PDO('mysql:host=myhost;dbname=mydb', 'login', 'password');
Posted by: Guest on August-09-2020

Browse Popular Code Answers by Language