Answers for "how to connect a db pdo via ssh"

PHP
0

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*/
Posted by: Guest on June-14-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