3

I try to connect to my batabase by means of php + adodb. This is my php code:

$kpp_db = ADONewConnection('odbc_mssql');
$kpp_db->debug = true;
$kpp_db->charSet="UTF-8";
$kpp_dbDSN = "Driver={SQL Server};Server=$kppConfig_dbHost;Database=$kppConfig_dbName;";
$kppConfig_akEnabled=$kpp_db->Connect($kppConfig_dbDSN, $kppConfig_dbLogin, $kppConfig_dbPassword);

But it's not work. I get the message

S1000: [unixODBC][FreeTDS][SQL Server]Unable to connect to data source

This is my /etc/odbc.ini file:

[SQL Server]
Driver=FreeTDS 
Description=testsql
Trace=Yes
TraceFile=~/workspace/mstest.log

And /etc/odbcinst.ini file:

[FreeTDS]
Description             = FreeTDS unixODBC Driver
Driver          = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup           = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
UsageCount              = 1

I confused. What is wrong?

vascowhite
  • 17,334
  • 9
  • 56
  • 73
Tamplier
  • 260
  • 2
  • 11
  • and what is your many `$` variable values? like `$kppConfig_dbHost` and `$kppConfig_dbName` – Amir Apr 16 '13 at 04:27
  • variables are defined. `$kppConfig_dbHost = '172.17.100.7'`, `$kppConfig_dbName = KPP_temp` and so on – Tamplier Apr 16 '13 at 04:33

2 Answers2

1

In redhat, but not sure for other linux OS.

You also have to allow apache/httpd to communicate with the MSSQL, Just type the command below, then restart httpd:

setsebool -P httpd_can_network_connect on
setsebool -P httpd_can_network_connect_db on

systemctl restart httpd

Then try to connected.

Omari Victor Omosa
  • 2,481
  • 1
  • 17
  • 39
0

Have you tried connecting through the command line like described here ? If both tsql and isql work, then your configuration files are not the problem. Depending on the OS you're using, this might be a permission issue. For me, disabling SELinux did the trick:

sudo setenforce 0
Community
  • 1
  • 1