Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,169
    Thanks
    19
    Thanked 65 Times in 64 Posts

    Connecting to MSSQL on Windows

    this is the ASP connection string I would normally use to connect to the SQL Server but I'm not sure how to convert this into a format that I can use in PHP to connect to the db.
    We're running PHP 5 on IIS and I'm trying to connect to SQL Server 7
    Code:
    Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=databasename;Data Source=NAK-HQ-DEV-01;Current Language=british;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=HQ-NAK-WS-01;

  • #2
    New Coder
    Join Date
    Jul 2005
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    mssql_connect($host, $username, $password);

    - Basically it's like using mysql_connect(), just replace the mysql_ with mssql_ . The same goes for the other db functions.

    Make sure the MSSQL extension is enabled (uncommented) in php.ini.

  • #3
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,169
    Thanks
    19
    Thanked 65 Times in 64 Posts
    ...I'd kinda got that far but what do I put as the host?

    also where would I find the php.ini?

  • #4
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,169
    Thanks
    19
    Thanked 65 Times in 64 Posts
    nevermind, just asked my boss if I could change the php.ini file and he said he's going to install mySQL... there was some reason that he didnt really explain but I'm not complaining lol...

  • #5
    New Coder
    Join Date
    Jul 2005
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The host would be "localhost" if the webserver is on the same machine as the MSSQL server.

    php.ini is usually found in c:/windows/ (or c:/winnt).


  •  

    Posting Permissions

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