Horje
php pdo connection Code Example
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();                         
}
pdo db connection
<?php
$pdo = new PDO('mysql:host=localhost;dbname=databasename', 'username', 'password');
?>
php PDO database connection
$hostName = "localhost";
$dbName = "test";
$userName = "test";
$password = "test1";
try {
    $pdo = new PDO("mysql:host=$hostName;dbname=$dbName",$userName,$password);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    echo "Connected successfully"; 
    }
    catch(PDOException $e)
    {
     echo "Connection failed: " . $e->getMessage();
    }
php how to connect to db using PDO
<?php 
  $db_src    = "mysql:host=localhost;dbname=databasename";
  $db_user   = "root";
  $db_pass   = "";
  try{
    $connect = new PDO($db_src, $db_user, $db_pass);
    $connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  }
  catch(PDOEXCEPTION $err){
    echo "Failed To Connect. Error " . $err->getMessage();
  }
/* Variable $connect will be used to execute DB Statements*/
php pdo sql server connect
$db = new PDO("sqlsrv:Server=YouAddress;Database=YourDatabase", "Username", "Password");
database connection in pdo php
$connect = new PDO("mysql:host=$host;dbname=$db", $user, $pass, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));




Php

Related
sort multi array php Code Example sort multi array php Code Example
Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) Code Example Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) Code Example
call to undefined function mysql_connect() Code Example call to undefined function mysql_connect() Code Example
jquery ajax 500 internal server error php Code Example jquery ajax 500 internal server error php Code Example
create array from string with commas php Code Example create array from string with commas php Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8