PDA

View Full Version : Installing php, mssql on centos5.0 - cant connect


ittec
26th November 2007, 12:43
About this tutorial: http://www.howtoforge.com/installing_php_mssql_centos5.0

Hello

i applied the HowToForge's tutorial of PHP5 and MSSQL but i can't connect to SQL Server(2005 or 2000). I tested the connection with this script:

$hostdbnot = "xxx";
$userdbnot = "xxx";
$passdbnot = "xxx";
$basedbnot = "xxx";

$dbgamesnot = mssql_connect($hostdbnot, $userdbnot, $passdbnot);
if ($dbgamesnot) echo 'Great!';
else echo 'Damn';
mssql_select_db($basedbnot, $dbgamesnot);

echo mssql_get_last_message();

The code returns "Damn" string. I have a php scritp with phpinfo() and this function returns as MSSQL is enabled.

mssql
MSSQL Support enabled
Active Persistent Links 0
Active Links 0
Library version FreeTDS

Are there any other action to try or test? Its very strange that phpinfo() shows MSSQL as enabled but its impossible to connect to Sql Server.

Thanks

falko
27th November 2007, 19:34
Any errors in Apache's error log? Are you able to connect to MSSQL on the command line?

ittec
28th November 2007, 12:05
Hi falko

i read yours answers and advices many times when ive found information about another issues :)

I tried to connect SQL server from comand line using tsql command (/usr/local/bin/tsql) but i cann't connect. I think this command try the hability of FreeTDS to connect to SQL Server.

# tsql -H [IP HOST] -p 1433 -U sa

Output:

locale is "en_US.UTF-8"
locale charset is "UTF-8"
Password:
Msg 20004, Level 9, State 0, Server OpenClient, Line 0
Read from SQL server failed.
Msg 20014, Level 9, State 0, Server OpenClient, Line 0
Login incorrect.
There was a problem connecting to the server

But the password is right. I don't see nothing in apache log error. Did i forgot something in freetds or odbc configuration?

Thanks :)

falko
29th November 2007, 16:54
Unfortunately I'm no MSSQL expert... :(
Is MSSQL running?

ittec
29th November 2007, 17:02
Unfortunately I'm no MSSQL expert

Like me :p

MSSQL is enabled but i can't connect to any SQL server by command or php script. I think the problem is a FREETDS configuration or maybe odbc.ini setup, but im totally lost.

The unbelieveable is MSSQL shows as enabled with phpinfo( ) :confused:

Any ideas?

Thanks Falko by your interest

ittec
4th December 2007, 18:28
Well with the help of Linux Gods we finally can connect to SQL Server 2000.

1) We followed the HowToForge tutorial (http://www.howtoforge.com/installing_php_mssql_centos5.0)

2) We experimented problems with Freetds. We installed well MSSQL extension but we couldn't connect to MSSQL from command line or php script. I found the solution of these issue here

http://www.centos.org/modules/newbb/viewtopic.php?topic_id=8249


INSTALANDO FREETDS
1- Entre na pasta de instalação do FreeTDS #cd /home/web/freetds
3- #./configure --prefix=/opt/web/freetds --with-tdsver=8.0 --enable-msdblib --enable-dbmfix --with-gnu-ld


The problem was i install Freetds from RPM with yum and didn't specifiy the parameters manually. I remove freetds rpm installation first, and then, install freetds manuall with parameters likie tdserver=8.0 etc. Later i copied the files of new installation to default directorys of a normal freetds installation.

Restart apache, and .... we could connect.

Thanks :)