Connect to DB Problem

witgrefe's profile image witgrefe posted 4 years ago in Creating a connection Permalink

I am trying to connect to a HeidiSQL db using php PDO on a linux machine. I cannot. This is the code I am using:

$dsn = "mysql:host=$host;dbname=$db;charset=$charset";

try {
            $conn = new PDO("mysql:host=$severname;dbname=$db", $user, $pass);
            $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            echo "Connected successfully";
      catch(PDOException $e) {
           echo "Connection failed:".  '</br>' . $e->getMessage();

The error returned is: could not find driver

Can someone help please


Please login to leave a reply, or register at first.