Steve Steve - 1 year ago 208
PHP Question

Connect xampp to online MSSQL database via PDO in php

I've installed xampp on my computer.
When I try to connect it tells me

Error!: could not find driver

When I run my code on my webhost, it works.

Some info:

XAMPP 3.2.2

MSSQL Server 2012

I connect with the following code:

define("USER_NAME", "myusername");
define("DATABASE", "mydatabase");
define("PASSWORD", "mypassword");
define("HOST", "myhost");

$db = new PDO("dblib:host=".HOST.";dbname=".DATABASE, USER_NAME, PASSWORD);
}catch(PDOException $exception){
echo $exception->getMessage();

I've downloaded these files, dropped them in the ext folder and added the following lines to php.ini:


Answer Source

Change this

$db = new PDO("sqlsrv:Server=YouAddress;Database=YourDatabase", "Username", "Password"); 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download