synking Posted March 26, 2012 Share Posted March 26, 2012 Hey, I need some help i am missing something i think i just don't know what. I have a centos server that a member of the domain. I have php apache installed and working. I want to connect to an mssql server that is used by the company for different reasons. I have installed freetds, linuxODBC. They are working perfect from the command line. I can connect to the mssql server via terminal. But i can not access the server through php and i am not sure why. Here is my php code. $vocname = 'voc'; $vocpass = 'VOC'; $vocserv = 'Driver={voc};Server=10.92.0.3:database=voc'; $vocdata = 'voc'; $link = mssql_connect($vocserv, $vocname, $vocpass); if (!$link) { die('Unable to connect or select database'); } # mssql_select_db($vocdata, $link); $version = mssql_query('SELECT @@VERSION'); $row = mssql_fetch_array($version); echo $row[0]; mssql_free_result($version); mssql_close($link); I have tried and bunch of differnet combos with the server name and connection type. I tried to use just the odbc php mod but that didn't work either. The only error i get in error_log from apache is that it is unable to connect. Can anyone give some advice. Quote Link to comment https://forums.phpfreaks.com/topic/259734-mssql-centos-php-unable-to-connect-to-database/ Share on other sites More sharing options...
synking Posted March 27, 2012 Author Share Posted March 27, 2012 If anyone winds up having this issue.... it is do to selinux something i thought i did but didn't. You have to allow httpd to network connect. Once you do that you can connect. Quote Link to comment https://forums.phpfreaks.com/topic/259734-mssql-centos-php-unable-to-connect-to-database/#findComment-1331561 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.