[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1053
  • Last Modified:

freetds connection error to MSSQL

I have a PHP script that makes a connection to a remote SQL Server. From the command line as root I can call the freetds command: tsql –H hostname –U username and it connects just great and I can run queries.

I have a PHP script in /var/www/html/axis/public/test.php
When I: sudo –u apache –s (change the user from root to apache) and then run my PHP script from the command line, it connects and runs the queries just great.
But when executing the same script from the web browser, it fails - the browser returns a DB Connection error. The web browser is able to connect everywhere it is supposed to and renders all the web pages that don't need an SQL connection.

apache is the user that is running httpd. I’ve confirmed this via: ps aux | grep apache

Any ideas as to why apache can execute the PHP script fine from the command line, but when the browser attempts to connect to the very same script, it fails?

Error!: SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (severity 9)
[/error]
0
casit
Asked:
casit
1 Solution
 
dhrusoftCommented:
you have allow host in remote server where you want connect .

check firewall in remote server .
0
 
RimvisCommented:
Hi casit,

>> Adaptive Server is unavailable or does not exist


Adaptive Server is NOT the same as MS SQL Server. It is a product from Sybase (now SAP), sharing same roots with MS SQL.
http://en.wikipedia.org/wiki/Adaptive_Server_Enterprise

Make sure you are connecting to the right server and using right libraries.
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Tackle projects and never again get stuck behind a technical roadblock.
Join Now