3

I have installed php-mssql package in Centos 6 for MSSql connection. I want to connect remote MSSql server from PHP 5.3.3.

My code:

$link = mssql_connect("192.168.*.*", 'username', 'password') or die ("Could not connect to database: ".mssql_get_last_message());
if (!$link) {
        die('Something went wrong while connecting to MSSQL');
}

But I am getting below error,

Warning: mssql_connect(): Unable to connect to server: 192.168.*.* in /var/www/html/test.php on line 22

If I use through freetds, it is working.

tsql -S192.168.*.* -Uusername -Ppassword

Please help me.

J.K
  • 1,382
  • 1
  • 11
  • 27
selvan
  • 1,183
  • 3
  • 16
  • 24

2 Answers2

4

try this and set network connect is 1 i.e on

setsebool -P httpd_can_network_connect 1
setsebool -P httpd_can_network_connect_db 1
JYoThI
  • 11,977
  • 1
  • 11
  • 26
2

It seems like you are being blocked by SELinux. If I'm right, executing these commands should solve your problem:

$ sudo -i 
  Password: 
# setsebool -P httpd_can_network_connect 1
# setsebool -P httpd_can_network_connect_db 1