Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8213527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:08:57+00:00 2026-06-07T11:08:57+00:00

I am having a problem connecting to MS SQL 2005 from PHP. I am

  • 0

I am having a problem connecting to MS SQL 2005 from PHP.

I am able to connect from the shell, using…

tsql -S 10.0.0.134 -p 1433  -U gareth 

Entering a simple query works as expected…

1> SELECT @@VERSION AS MSSQL_VERSION
2> go
MSSQL_VERSION   
Microsoft SQL Server 2005 - 9.00.4035.00 (Intel X86) 
Nov 24 2008 13:01:59 
Copyright (c) 1988-2005 Microsoft Corporation
Express Edition on Windows NT 6.1 (Build 7601: Service Pack 1)

However, trying this from a PHP script does not work…

$test = mssql_connect('10.0.0.134:1433', 'gareth', 'mypass');

… and produces an mssql_connect() [function.mssql-connect]: Unable to connect to server error.

I can see the mssql.so module in /usr/lib/php/modules and phpinfo() shows the module is loaded.

I’d be happy to use odbc_connect instead if someone could show me an example configuration for freetds.conf and odbc.conf

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T11:08:58+00:00Added an answer on June 7, 2026 at 11:08 am

    Here is what i could find on PHP.net about your problem. Maybe it will help you solve it.

    This might be obvious to some, but here is a quick tidbit that might save you some time if you are using FreeTDS in Linux:
    Be sure that you have these two lines in freetds.conf:
    dump file = /tmp/freetds.log
    dump file append = yes
    
    so you can tail -f it in the background of debugging the problem.  This helped me find my issue on on CentOS Linux: 
    
    1) tsql test works
    
    2) php-mssql connection in php also works WHEN RUN FROM THE SHELL
    
    3) running PHP through apache does NOT work.
    
    my /tmp/freetds.log file told me: 
    net.c:168:Connecting to MYDBSERVER port MYDBPORT
    net.c:237:tds_open_socket: MYDBSERVER:MYDBPORT: Permission denied
    
    and the answer was my firewall/SELinux was denying the Apache processes access to connect to the remote MSSQL DB port, but my shell accounts were fine.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having problems when connecting to a legacy database in SQL Server. The problem
I am having a problem getting a result set from my Sql Server 2008
I’m having a problem with my SQL Connection strings not using the authentication provided
I'm having a problem using VBA to execute a SQL query and copy the
I am having a problem connecting to the server hosting my webservice when I
Our application downloads data from the internet using RSS but is having connection problems
I'm having a never-ending problem with trying to call a stored procedure from a
I am currently having a problem selecting a certain item from a mySQL database.
Having a problem with IIS on Windows Server 2003 (using a classic ASP web
I am having problem converting my SQL query to LINQ. How would you create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.