0

Please could you help me with on how to connect to a MSSQL server 2012 via php 5.5.15 (on uWamp, a portable version of wamp) with windows auth.

I can connect using SQL Server Management Studio with the following settings: Server Type: Database Engine Server Name: SVV-WAREHOSSE2\BIDWH Authentication: Windows Authentication Database: DX_REP

I only have access to the views on this database.

i used the following script to try and connect

<?php  
$serverName = "SVV-WAREHOSSE2\BIDWH"; 
try {  
   $conn = new PDO( "sqlsrv:Server=$serverName;Database=DX_REP", NULL, NULL);   
   $conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );  
}  

catch( PDOException $e ) {  
   die( "Error connecting to SQL Server" );   
}  

echo "Connected to SQL Server\n";  

?>

My PHP INI extensions looks like this:

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

; If you wish to have an extension loaded automatically, use the following
; syntax:
;
;   extension=modulename.extension
;
; For example, on Windows:
;
;   extension=msql.dll
;
; ... or under UNIX:
;
;   extension=msql.so
;
; ... or with a path:
;
;   extension=/path/to/extension/msql.so
;
; If you only provide the name of the extension, PHP will look for it in its
; default extension directory.
;
; Windows Extensions
; Note that ODBC support is built in, so no dll is needed for it.
; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
; extension folders as well as the separate PECL DLL download (PHP 5).
; Be sure to appropriately set the extension_dir directive.
;
extension=php_bz2.dll
extension=php_curl.dll
extension=php_fileinfo.dll
extension=php_gd2.dll
extension=php_gettext.dll
;extension=php_gmp.dll
extension=php_intl.dll
extension=php_imap.dll
;extension=php_interbase.dll
extension=php_ldap.dll
extension=php_mbstring.dll
extension=php_exif.dll      ; Must be after mbstring as it depends on it
extension=php_mysql.dll
extension=php_mysqli.dll
;extension=php_oci8.dll      ; Use with Oracle 10gR2 Instant Client
;extension=php_oci8_11g.dll  ; Use with Oracle 11gR2 Instant Client
extension=php_openssl.dll
;extension=php_pdo_firebird.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_pspell.dll
extension=php_shmop.dll
; The MIBS data available in the PHP distribution must be installed. 
; See http://www.php.net/manual/en/snmp.installation.php 
;extension=php_snmp.dll
extension=php_soap.dll
extension=php_sockets.dll
extension=php_sqlite3.dll
;extension=php_sybase_ct.dll
extension=php_tidy.dll
extension=php_xmlrpc.dll
extension=php_xsl.dll

Any help would be greatly appreciated, am i missing any extensions? or is my connection string incorrect? or have i done something else wrong.

jarlh
  • 42,561
  • 8
  • 45
  • 63
kayboxa
  • 37
  • 6
  • 1
    WAMP means **W**indows, **A**pache, **M**ySQL and **P**HP, not **W**indows, **A**pache, *S*QL Server and **P**HP (That was be WASP ;) ). If you're using a true WAMP, it's design for use against MySQL, not SQL Server. – Thom A Dec 17 '19 at 16:33
  • i think you are mistaken by the query, i have wamp but i'm trying to connect to a mssql server on a server which is elsewhere to try and create a php dashboard. – kayboxa Dec 17 '19 at 16:38
  • I'm not looking at your query at all; I'm talking specifically about what you're saying you're using. a WAMP doesn't use SQL Server. – Thom A Dec 17 '19 at 16:48
  • 1
    Not really used [PDO with SQL server](https://stackoverflow.com/questions/12747554/connect-to-sql-server-through-pdo-using-sql-server-driver) but it *looks* like you're missing the [pdo_sqlsrv](https://www.php.net/manual/en/ref.pdo-sqlsrv.php) extension... otherwise you'd need to [connect with odbc](https://stackoverflow.com/questions/20163776/connect-php-to-mssql-via-pdo-odbc). – CD001 Dec 17 '19 at 17:00
  • 1
    @kayboxa You need to install PHP Driver for SQL Server. Just follow the steps in this [answer](https://stackoverflow.com/questions/53664188/how-to-connect-sql-server-with-php-using-xampp/53680488#53680488). – Zhorov Dec 17 '19 at 18:06
  • @ZHOROV thank you, this worked. – kayboxa Dec 18 '19 at 17:56
  • @kayboxa Glad to help! – Zhorov Dec 18 '19 at 17:56

0 Answers0