sanoj lawrence sanoj lawrence - 1 year ago 76
PHP Question

could not find driver in wamp php after run

am using following code to connect to database

//database credentials
define('DBHOST', 'localhost');
define('DBUSER', 'sanoj');
define('DBPASS', '123456');
define('DBNAME', 'test');

//application address
define('DIR', '');
define('SITEEMAIL', '');

try {

//create PDO connection
$db = new PDO("mysql:host=" . DBHOST . ";port=3306;dbname=" . DBNAME, DBUSER, DBPASS);
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$db->exec("SET NAMES 'utf8';");
} catch (PDOException $e) {
//show error
echo '<p class="bg-danger">' . $e->getMessage() . '</p>';

after i run my php file from netbeans ide i get nothing except this

could not find driver

i tried all method checking

and even read this tofind some solution
but cant find whats wrong

i used this code in PC it worked well but when i try this on my laptop i get this error how can i solve this problem

am using windows 64bit
but previouly i used 32bit

Answer Source

Sorry for bad english!

Create a file named info.php with this content:


Save and put in your server root.
Access http://localhost/info.php
See what PDO Drivers are loaded (CTRL + F and type PDO drivers).
MySql PDO Driver need to be loaded like this: pdo mysql

If you don't see mysql on PDO drivers, you should edit php.ini and add extension=pdo_mysql.dll
Restart your Apache and try again in info.php

PS: Certify that you have the pdo_mysql.dll in your PHP extensions folder.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download