-1

Ok, here is my situation:

I have installed Xampp (v1.8.2) on my server to publish a webprogram i am making (php, html) for some people in my network. For the first time i have to connect to MSSQL 2008 server instead of MYSQL (phpmyadmin). over the past years i've always worked with the MySQL api and a little with MySQLi. I have read over the internet i must use PDO so i can succesfully connect to the MS database.

As i can see PDO is not installed/activated. When i look into the PHP.ini file the only thing i see is:

extension=php_mssql.dll

but no

extension=php_pdo_mssql.dll

i've read allot (i.e that i have to install soms dll files, that i have to install apache, PHP, PDO manually)

What is the good way to make a successful connection to my mssql database?

Thanks

Raz3rt
  • 69
  • 1
  • 3
  • 11
  • Check this: http://stackoverflow.com/questions/16310892/mssql-pdo-could-not-find-driver – Aniruddh Jan 15 '14 at 13:31
  • Thanks! Because of your push in my back i was able to find the following thread: http://stackoverflow.com/questions/7402713/how-to-get-mssql-work-with-php-5-3. Answer of gordon made my day and let it works like a charm! had i found this 2 days earlier i would have been saved a lot of precious time! – Raz3rt Jan 15 '14 at 14:43
  • Glad I could help somehow. :) – Aniruddh Jan 16 '14 at 09:12

2 Answers2

0

Though using PDO is a nice idea and will save you time, you can use Mssql extension. If you really want to use PDO_MSSQL, you should allow it in PHP.ini (the second string you posted is the right way to do that), but you should also have php_pdo_mssql.dll in your PHP's extension directory. You can find that file here

Kei
  • 771
  • 6
  • 17
  • Thanks for poiting me in a good direction. I work with PHP 5.4 and according to this: "The MSSQL extension is not available anymore on Windows with PHP 5.3 or later. SQLSRV, an alternative driver for MS SQL is available from Microsoft" mssql is not an option anymore. – Raz3rt Jan 15 '14 at 14:46
  • Is there a reason you suggest Mssql instead of PDO? – Kenny Johnson Dec 05 '14 at 15:25
  • In my answer I didn't suggest Mssql extension over PDO_MSSQL. Simply they are alternatives and as such I suggested the other if the latter wasn't available. In OP question we can clearly see that Mssql extension is enabled, hence usable. That's why I suggested to use Mssql. Also sometimes PDO drivers do not support special features. However if I were to choose between normal extension and PDO I'd prefer PDO. – Kei Dec 06 '14 at 17:43
0

There are two MSSQL extensions: SQLSRV http://php.net/manual/en/book.sqlsrv.php (if your server/computer is a Windows box) and MSSQL http://php.net/manual/en/book.mssql.php (if your server/computer is a Linux or OSX box)

If you are using Windows: use the SQLSRV PHP extension http://www.microsoft.com/en-us/download/details.aspx?id=20098.

If you use Linux/Debian follow the instructions in this article. If you use OSX, try something like this article http://blog.andyhunt.info/2013/11/29/php-mssql-pdo_dblib-freetds-support-on-mac-osx-10-9-mavericks/.

I am writing a basic MSSQL Database Object which is compatible with both the extensions: https://github.com/janjuna/mssql-db

janhenkes
  • 107
  • 6
  • Is there a reason you suggest MSSQL instead of PDO? Everything I've been reading says to replace mysql_* functions with PDO. Is MSSQL now superior to PDO? – Kenny Johnson Dec 05 '14 at 15:26
  • mysql; mssql; and PDO are basically three different things, I suggest you learn the difference between them, before deciding which to use. – Kei Dec 06 '14 at 18:06