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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With