- Windows Server 2016 64 bit (Fully Updated)
- WAMP/3.1.3 (Win32)
- Apache/2.4.33 (Win32)
- PHP/7.2.4 (Win32)
I am trying to connect to my database on a SQL Server but can't seem to get the connection working. I have tried several approaches, downloaded files, enabled extensions but none of them seem to work. I have established that the SQL Server has Named Pipes and that Remote Connections are allowed. I have also confirmed that he password and username work:
<?php
$driver='{ODBC Driver 17 for SQL Server}';
/* $driver='{ODBC Driver 13 for SQL Server}'; */
/* $driver='{ODBC Driver 11 for SQL Server}'; */
$dsn='phpodbc11';
$hostname='host01';
$database='data01';
$username='root';
$password='pass123';
$conn = new PDO("odbc:$dns")
$conn = new PDO("dblib:host=$hostname;dbname=$database", $username,$password);
$conn = new PDO("sqlsrv:Server=$hostname;Database=$database", $username, $password);
$conn = new PDO("odbc:Driver=$driver;Server=$hostname;Database=$database", $username, $password);
?>
php.ini extensions :
- extension=pdo_odbc
- extension=php_mysqli.dll
- extension=php_ldap.dll
- extension=php_pdo_sqlsrv_72_ts_x86.dll
- extension=php_sqlsrv_72_ts_x86.dll
Errors I get for each of the aforementioned new PDO attempts
*SQLSTATE[IM002] SQLConnect: 0 [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
could not find driver
SQLSTATE[IMSSP]: This extension requires the Microsoft ODBC Driver for SQL Server to communicate with SQL Server. Access the following URL to download the ODBC Driver for SQL Server for x86: https://go.microsoft.com/fwlink/?LinkId=163712
SQLSTATE[IM002] SQLDriverConnect: 0 [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified*