Answers for "pdo db2 php"

PHP
2

how to connect pdo php database

<?php
$servername = "localhost";
$username = "username";
$password = "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();
}
?>
Posted by: Guest on May-14-2020
0

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();
    }
Posted by: Guest on May-17-2021
0

php pdo sql server connect

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

Browse Popular Code Answers by Language