Php mysql connection with PDO in IIS
The following code shows when executed:
could not find the driver.
I have already changed the extension = php_pdo_mysql.dll
from the comment and also restarted the server, but it still shows that the driver was not found. I am using mysql5.7
php 7.1.6
and iis10
.
<?php
$hostname='localhost';
$username='root';
$password='';
try {
$dbh = new PDO("mysql:host=$hostname;dbname=stickercollections",$username,$password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo 'Connected to Database<br/>';
$sql = "SELECT * FROM stickercollections";
foreach ($dbh->query($sql) as $row)
{
echo $row["collection_brand"] ." - ". $row["collection_year"] ."<br/>";
}
$dbh = null;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
?>
+3
source to share