The mysql PDO interface
Posted by: sweety (---.net.upcbroadband.cz)
Date: June 10, 2012 09:04PM

helo, i got the follwng error:-

The mysql PDO interface
-->connect and select database
Error: could not find driver

so wat shuld i do for dis error plz help me.... n i hav the foolwng code fpr furthr refrnce.....

<h3>The mysql PDO interface</h3>
<?php // mysql-pdo-test.php
try {
$user = "guest"; $pass = "";

echo "-->connect and select database\n";
$dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass);

# activate exception generation
$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );

echo "<br />-->create table:\n";
$dbh->exec( "CREATE TABLE IF NOT EXISTS test_tab (thing VARCHAR(10))" );

echo "<br />-->insert into table:\n";
$dbh->exec( "INSERT INTO test_tab VALUES ('book'),('pencil')" );

echo "<br />-->select from table:\n";
$res = $dbh->query( "SELECT thing FROM test_tab" );
foreach ($res as $row) {
echo $row['thing'], " ";
}

echo "<br />-->drop table:\n";
$dbh->exec( "DROP TABLE test_tab" );
echo "<br />SUCCESS!";

// disconnect
$dbh = null;
}
catch (PDOException $e) {
die( "<h4>Error: " . $e->getMessage() . "</h4>" );
}
?>



by refrng d abv code can any1 help me 2 com out of d error whch i included in very 1st of dis page..........

waiting.....

Re: The mysql PDO interface
Posted by: RiggsFolly (---.as13285.net)
Date: June 12, 2012 10:40AM

This is going to sound silly, but have you checked that the pdo_mysql extension in PHP has been enabled right?

left click wamp manager -> PHP -> PHP extensions

Look down the list and check that php_pdo_mysql is ticked.

Watch out as the extension for mssql and mysql look very similiar. Make sure the correct one is ticked!!

Sorry, only registered users may post in this forum.