Search
 
SCRIPT & CODE EXAMPLE
 

PHP

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();                         
}
Comment

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();
    }
Comment

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*/
Comment

php pdo sql server connect

$db = new PDO("sqlsrv:Server=YouAddress;Database=YourDatabase", "Username", "Password");
Comment

database connection in pdo php

$connect = new PDO("mysql:host=$host;dbname=$db", $user, $pass, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
Comment

PREVIOUS NEXT
Code Example
Php :: The uploaded file exceeds the upload_max_filesize directive in php.ini. 
Php :: what is abstract class in php 
Php :: laravel search multiple (related) tables 
Php :: how to insert data in table and fetch in wordpress 
Php :: Codeigniter 3 Get future date recocords - upcoming records from database 
Php :: php self referencing form 
Php :: laravel auth 
Php :: laravel where null 
Php :: custom timestamp column laravel 
Php :: laravel fontawesome blade directive 
Php :: Show all laravel valet folders 
Php :: switch php version ubuntu 20.04 
Php :: how to make a child theme in wordpress 
Php :: wordpress debug mode 
Php :: php pdo setting error modes 
Php :: php execute command and display output 
Php :: ci4 throw new exception 
Php :: laravel api cors localhost issue 
Php :: laravel use config 
Php :: php include once inside a function? 
Php :: php + set timezone berlin 
Php :: how to free session variable in php codeigniter 
Php :: count column eloquent laravel 
Php :: php validate credit card expiration date 
Php :: laravel route multiple middleware 
Php :: Main features of php 
Php :: Movie Name -inurl:(htm|html|php|pls|txt) intitle:index.of “last modified” (mp4|wma|aac|avi) 
Php :: how to declare global variable in laravel controller 
Php :: sort by number of views descending laravel 
Php :: static class methods php 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =