0
votes

I'm using PHP Version 5.6.25 that was installed via WAMPP. I'm having issues connecting to my database on mySQL DB:

$server = 'jdbc:sqlserver://DB-1\POWERPIVOT;databaseName=SBV_Foldio';
$user = 'sa';
$pass = 'host';

I had check PDO extension and already install

if (!defined('PDO::ATTR_DRIVER_NAME')) {
echo 'PDO is unavailable<br/>';
}
elseif (defined('PDO::ATTR_DRIVER_NAME')) {
    echo 'PDO is available<br/>';
}

PDO is available

but when i run connection

try {
$dbh = new PDO($server, $user, $pass);

$dbh = null;
} catch (PDOException $e) {
    print "Error!: " . $e->getMessage() . "<br/>";
}

it failed

Error!: could not find driver

1
phpinfo(); check if you have pdo_mysql in there. In case you are on Linux: check whether you have the proper packages installed: dpkg --get-selections | grep php5-mysql - Xatenev
yeah i have pdo_mysql block in there phpinfo() - VendettaV
Your problem is that you don't have the PDO_ODBC module installed. See php.net/manual/en/ref.pdo-odbc.php - UPDATE: I wrote an answer. - Xatenev
I'm using window, and i had enabled all the extension i can in php.init but still dont work - VendettaV

1 Answers

0
votes

The problem is that you do not have the PDO_ODBC module installed right now. PDO seems to be properly configured & installed. See http://php.net/manual/en/ref.pdo-odbc.php for more info.

You are obviously running windows, so:

On Windows, php_pdo_odbc.dll has to be enabled as extension in php.ini. It is linked against the Windows ODBC Driver Manager so that PHP can connect to any database cataloged as a System DSN, and is the recommended driver for connecting to Microsoft SQL Server databases.