How to Connect PHP and SQL Server 2008 using XAMPP 1.7.3

Posted: 20 February 2011 in IT

There are the ways that I used to connect PHP to SQL Server 2008  from zero to finish:

I. SQL Server 2008: Must have user login & password, use SQL Server Authentication mode.

1.       First, plase connect your database by Windows Authentication. My server name that I used is: .\SQLEXPRESS

2. Select Security folder -> Logins -> New Login

3. Setting at General tab:

Fill in the Login Name that you want, use SQL Server authentication mode, give the password!

4. At Status tab, make sure the Permissions to the connect database engine = Grant, and Log = Enable.

And for the other tabs / option (Server Roles, User Mapping, Securables) could be tailored as you want. After that click OK!

5. Next, right click on the servers. \ SQLEXPRESS, click properties:

6. At Security tab, select Server authenctication become SQL Server and Windows Authentication mode.

7. Next setting, right click at the .\SQLEXPRESS server, select Facets

8. On dropdown-list Facet, select Server Configuration, change RemoteDacEnables become True

9. Also at Facet: Surface Area Configuration, select RemoteDacEnables become  True too. Click OK !

10. Until this stage, the SQL Server configuration is complete. Prove to login using your username and password that was configured earlier. Disconnect, then connects again!

SUCCSESS . . !!

II.  PHP Configuration (XAMPP 1.7.3)

1.       Before performing the configuration, make sure the apache server is not in “start” condition, a.k.a turn off!

2.       Download the latest version of ntwdblib.dll file (search on google), then copy to: XAMPP / Apache / bin, replace!

3.       Open the php.ini file in the folder: / xampp / php / php.ini (also can be opened on notepad),

Remove the semicolon (;) before extension = php_mssql.dll, this means php_mssql.dll extension enabled.

4. Now you can re-enabled Apache server.

III. Connection Testing

Type the following in a text editor, this example is my case. Customize your Server Name, User Login, and Password as you setup earlier.

After the execution, should see the message “DB connection successful”.

GOOD LUCK ^ _ ^

About these ads
Comments
  1. sharon says:

    i tried this to sql server 2005…but i cant find the parse…can you please guide me?

    thanks

    • YoQ Adrian says:

      What parse you cant find ?
      I have tried too at SQL Server 2005 (Express, Management Studio), and it’s not a problem.
      The most important is how to create a login with username and password on sql server authentication mode and make sure php_mssql.dll extension on active condition.

  2. happyblog88 says:

    Yoq klo XAMPPnya versi 1.7.4 kumaha? Hrs download ntwdblib.dll ga? Ato udah include di XAMPP versi 1.7.4 tsb? N trs ketik connection testingnya di editor apa? Editor SQL Server bukan?

  3. Paulrugz says:

    I’ve done it, but it show warning message as “PHP Startup: mssql: Unable to initialize module Module complied with module API=20060613 PHP complie with module API=20090626 These options need to match

  4. shunmugam says:

    i have follow the above step but error message shows “PHP SQL Server interface is not installed, cannot continue.” and also says “Call undefined function mssql_connect”

  5. Erika says:

    Hello,

    would you be able to give me a copy of your php_mssql.dll that is running with XAMPP.
    Also I have read in some other forums/tutorials that I need ntwlib.dll or something like that but their tutorials are sort of confusing while yours is very clear. I am just not sure that I have all the dlls needed or files needed to connect as I end up messing with phpmyadmin or apache whenever I change dlls or add the dlls i download from net, I might be downloading incompatible ones. Your help will be very much appreciated. :)

  6. erikaliza says:

    Hello,

    Would it be possible for you to provide me by email or by posting here a copy of your php_mssql.dll or if possible your entire xampp folder, except your htdocs ofc. This is because I seem to be downloading wrong version of dlls and my computer also loads the configuration from C://WINDOWS instead of XAMPP.

    If possible, I would greatly appreciate your help in configuring my xampp. I think I have a lot of missing dlls.

    Thank you in advance :)

  7. riqtarunk says:

    permisi gan numpang tanya klo cara nampilin tabel di sql server 2008 ke php itu gmana ya caranya? minta tolong bantuannya gan. thamks

  8. narendra kumar says:

    After enable the extension=php_mssql.dll still i am getting the error undefined function mssql_connect .

  9. lexzios says:

    php_mssql.dll couldn’t found eventhough I’ve copied it to xampp/php/ext
    any help?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s