freetds.conf:
[localz2]
host = 10.0.0.2
port = 1433
tds version = 8.0
Pretty straight forward, and works fine with tsql. With tsql I can connect and query the database.
PHP code:
$mssql_connection = mssql_connect('localz2','sa', 'password');
This insists:
Warning: mssql_connect(): Unable to connect to server:
I'm pulling my hair out, what is left of it, over this one. Why, oh why, would tsql work but mssql_connect in PHP not?
Note this has nothing to do with a web server, I'm running the php code in a console.
Slackware 14.1 32 bit
PHP 5.5.16
tsql works, php doesn't, accessing MSSQL DB
Moderator: General Moderators
Re: tsql works, php doesn't, accessing MSSQL DB
Try a different tds version - 7.2 or 7.0, for instance.
Re: tsql works, php doesn't, accessing MSSQL DB
I had to change it to 8.0 just to get it to work with tsql. With it set to 7.0, it wouldn't even work with tsql.
But oddly enough I found this in my PHP ./configure parms:
'--with-mssql=/usr/local/freetds'
Which is wrong, it has to be:
'--with-mssql=/usr/local'
And that was all it took to get PHP working. When I configure freetds I was pretty sure I used:
./configure --prefix=/usr/local
because if you put freetds in /use/local/freetds it won't work with PHP even if you configure PHP with '--with-mssql=/usr/local/freetds' and I haven't had the time to figure out why.....weird...I must have been using and old ./configure line when I upgraded PHP.....
But oddly enough I found this in my PHP ./configure parms:
'--with-mssql=/usr/local/freetds'
Which is wrong, it has to be:
'--with-mssql=/usr/local'
And that was all it took to get PHP working. When I configure freetds I was pretty sure I used:
./configure --prefix=/usr/local
because if you put freetds in /use/local/freetds it won't work with PHP even if you configure PHP with '--with-mssql=/usr/local/freetds' and I haven't had the time to figure out why.....weird...I must have been using and old ./configure line when I upgraded PHP.....