+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
Coding Thread, PHP and MSSQL in Coding and Web Development; Hello all, Having some problems getting PHP to connect to my MSSQL database. I am trying to write an application ...
  1. #1

    Join Date
    Jan 2009
    Location
    Weston Super Mare
    Posts
    66
    Thank Post
    2
    Thanked 2 Times in 2 Posts
    Rep Power
    13

    PHP and MSSQL

    Hello all,

    Having some problems getting PHP to connect to my MSSQL database.

    I am trying to write an application in PHP that needs to connect to a MSSQL database. I am running PHP5.3.1, and IIS for the web part SQL Express.

    Can anyone help me in the configuration of the PHP side of things? I have read a few articles and am very confused?

  2. #2
    hit
    hit is offline
    hit's Avatar
    Join Date
    Mar 2008
    Location
    London
    Posts
    326
    Thank Post
    49
    Thanked 50 Times in 48 Posts
    Rep Power
    51
    Meh, I replied before and then re-read your post which made mine look stupid so I deleted it, so let's start again!

    which bit of the configuration do you need help with? Is it actual PHP code to make a connection or configuration of IIS?

  3. #3

    Join Date
    Jan 2009
    Location
    Weston Super Mare
    Posts
    66
    Thank Post
    2
    Thanked 2 Times in 2 Posts
    Rep Power
    13
    Hi there,

    Thats okay.

    I have got the code to make to connection to the database, but i have read that you need to move DLL files, and change the php.ini config to get it working?

    Matt

  4. #4
    hit
    hit is offline
    hit's Avatar
    Join Date
    Mar 2008
    Location
    London
    Posts
    326
    Thank Post
    49
    Thanked 50 Times in 48 Posts
    Rep Power
    51
    It sounds like you are using a third party php application, if so, which one? I haven't usually needed to move anything around, just make sure everything is registered properly.

    So, let's get started:
    Which version of IIS are you using and on what server?
    Is the sqlexpress instance the only one on the machine and does its use default ports?
    Can you log in to the sqlexpress instance with Mssql management studio?
    Is the IIS service running? If so can you get a PHPINFO() page to run in the default site?

  5. #5

    Join Date
    Jan 2009
    Location
    Weston Super Mare
    Posts
    66
    Thank Post
    2
    Thanked 2 Times in 2 Posts
    Rep Power
    13
    Quote Originally Posted by hit View Post
    It sounds like you are using a third party php application, if so, which one? I haven't usually needed to move anything around, just make sure everything is registered properly.

    So, let's get started:
    Which version of IIS are you using and on what server?
    Is the sqlexpress instance the only one on the machine and does its use default ports?
    Can you log in to the sqlexpress instance with Mssql management studio?
    Is the IIS service running? If so can you get a PHPINFO() page to run in the default site?
    Hiya,

    Im not using a third party application. Just IIS with the PHP extensions installed.
    In answer to your questions IIS is version 6, and is on a windows server 2003 server.
    Yes it is the only SQL instance, and i can log into it with the managment studio.
    Yes IIS is running, and yes i can get the phpinfo to run.

    Matt

  6. #6
    hit
    hit is offline
    hit's Avatar
    Join Date
    Mar 2008
    Location
    London
    Posts
    326
    Thank Post
    49
    Thanked 50 Times in 48 Posts
    Rep Power
    51
    Hi Matt, so, OK everything sounds like its running OK, is there a sqlsrv section in the output from the PHPINFO? If there is then everything should be good to go!

    What do you get if you run the following?
    Code:
    <?php
    $server = 'SERVER\INSTANCE';
    
    //*Connect to MSSQL
    $link = mssql_connect($server, 'USERNAME', 'PASSWORD');
    
    if (!$link) {
       die('');
    }
    ?>
    You can also try to replace 'SERVER\INSTANCE' with 'IPADDRESS,PORT'.
    Last edited by hit; 30th May 2012 at 09:38 PM.

  7. #7

    Join Date
    Jan 2009
    Location
    Weston Super Mare
    Posts
    66
    Thank Post
    2
    Thanked 2 Times in 2 Posts
    Rep Power
    13
    Hi there,

    I get the follwoing when i run that code:

    Parse error: parse error in C:\DFSRoots\NewVis\Network\info.php on line 2

    Also there is no sqlsrv section in the phpinfo??

  8. #8
    hit
    hit is offline
    hit's Avatar
    Join Date
    Mar 2008
    Location
    London
    Posts
    326
    Thank Post
    49
    Thanked 50 Times in 48 Posts
    Rep Power
    51
    Ahh, just looked back and noticed server 2003 + PHP 5.3.

    SQLSRV isnt available for 2003, only vista, 7 and 2008. The old MSSQL driver and commands were taken out from PHP 5.3 and above.

    Not really sure where to go from here for you apart from using an earlier version of PHP or using server 2008. I would go with the latter if you can.

    Sorry!

  9. #9

    Join Date
    Jan 2009
    Location
    Weston Super Mare
    Posts
    66
    Thank Post
    2
    Thanked 2 Times in 2 Posts
    Rep Power
    13
    Ahh thats a real shame. I dont think i can really go back to a later version of PHP, and there is definatly not an option to move it over to server 2008.

    Looks like i am stuck then unless anyone has any other ideas?

    Looking at the overall picture, this is what i am trying to do:

    We have lansweeper running on a sevrer, and i am basically trying to pull some data from the lansweeper database, to display in my PHP application. If anyone knows of any other way to do this, then that would be a great help!

  10. #10

    Join Date
    Jan 2009
    Location
    Weston Super Mare
    Posts
    66
    Thank Post
    2
    Thanked 2 Times in 2 Posts
    Rep Power
    13
    Just been doing a bit of googleing, and have come across this. Do you think it might work?

    MSSQL Driver for PHP5.3 | Abby and Win's Blog

  11. #11
    hit
    hit is offline
    hit's Avatar
    Join Date
    Mar 2008
    Location
    London
    Posts
    326
    Thank Post
    49
    Thanked 50 Times in 48 Posts
    Rep Power
    51
    Looking here System Requirements (Microsoft Drivers for PHP for SQL Server) it appears that you may be in luck with the version 2 of the driver.

    Looks like you are back on track

  12. #12

    Join Date
    Jan 2009
    Location
    Weston Super Mare
    Posts
    66
    Thank Post
    2
    Thanked 2 Times in 2 Posts
    Rep Power
    13
    Ahh fantastic. I will give that a go at work tomorrow. Thanks for all your help, and i will let you know how i get on!!

  13. #13

    Join Date
    Jan 2009
    Location
    Weston Super Mare
    Posts
    66
    Thank Post
    2
    Thanked 2 Times in 2 Posts
    Rep Power
    13
    Hi All,

    Okay. Got in this morning, and this is the first thing i got to work on! I followed the instructions, and dowloaded v2.0 of the driver. I put the dll file in the ext directory, and am now getting the following error message when i restart IIS ... PHP Startup: Unable to load dynamic library 'C:\Program Files\PHP\ext\php_sqlsrv_53_nts_vc9.dll' - The specified module could not be found.

    I have double checked, and the file is there, and have also double checked the spelling the php.ini. All seems to be correct?? Any ideas?

    Matt

  14. #14

    Join Date
    Jan 2009
    Location
    Weston Super Mare
    Posts
    66
    Thank Post
    2
    Thanked 2 Times in 2 Posts
    Rep Power
    13
    Hiya,

    Finally got it working, by trying every version of the driver that was in the package that i downloaded. Turns out that the correct file is the php_sqlsrv_52_ts_vc6.dll

  15. #15
    hit
    hit is offline
    hit's Avatar
    Join Date
    Mar 2008
    Location
    London
    Posts
    326
    Thank Post
    49
    Thanked 50 Times in 48 Posts
    Rep Power
    51
    Quote Originally Posted by gream0604 View Post
    Hiya,

    Finally got it working, by trying every version of the driver that was in the package that i downloaded. Turns out that the correct file is the php_sqlsrv_52_ts_vc6.dll
    Excelent stuff, will have to remember this for myself!



SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. [PHP] PHP and MySQL
    By MK-2 in forum Web Development
    Replies: 4
    Last Post: 28th June 2011, 01:21 PM
  2. PHP and LDAP on IIS
    By srochford in forum Windows
    Replies: 2
    Last Post: 31st October 2007, 10:05 AM
  3. Office 2007 file format support in Apache, PHP and Moodle
    By Geoff in forum Virtual Learning Platforms
    Replies: 2
    Last Post: 8th July 2007, 01:12 AM
  4. PHP and IP Address lookup
    By plexer in forum Web Development
    Replies: 0
    Last Post: 27th March 2007, 12:17 PM
  5. Creating a new database in php and mysql
    By StewartKnight in forum Web Development
    Replies: 18
    Last Post: 21st February 2007, 09:53 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •