I'm trying to connect Access Database to my website via PHP, Using PDO . But, I'm getting this strange message
Data source name not found and no default driver specified.
I'm fully aware that there are multiple questions and answers regarding the same on Stack Over Flow but none of them worked for me.
this is my code to connect to my Access database .
<?php
$dbname = 'Sea_Service_Certificates.accdb';
if(!file_exists($dbname)){
echo "not found";
}
$inp = $_POST["input"];
echo $inp . "<br>";
try {
$db = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$dbname;Uid=; Pwd=;");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "Select *from Certificate Details where PassportNumber =
"+$inp+";";
$result = $db->query($sql);
$row = $result->fetch();
$name = $row["Name"];
echo "<h1><a href='index.php'>$name</a></h1>";
} catch (PDOException $e) {
echo "Error : " . $e->getMessage()."<br>";
}
?>
The code works like a charm in local host but when I upload to my web host which is BIGROCKS it doesn't work and throws the error.
I did every possible solution on the internet including customizing my php.ini file .
Thanks in advance.