Skip to Content.
Sympa Menu

freetds - [freetds] FreeTDS w/ unixODBC, PHP and Apache

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Nelson Neves Marques <Nelson.Marques AT artelecom.pt>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] FreeTDS w/ unixODBC, PHP and Apache
  • Date: Tue, 11 Mar 2008 09:32:58 +0000

Hello,



I'm currently trying to configure FreeTDS with unixODBC, PHP and Apache.



I'm using the 0.64 version and it works fine for PHP in the command
line. However, when I try to run the same file on Apache it doesn't
connect to the database.



Can you help me with this issue. Below are both scenarios with the
respective odbc trace files.



Thanks,



Nelson Marques





########################################################################
############



[root@localhost html]# cat /etc/odbc.ini

[MSSQLTestServer]

Driver = FreeTDS

Description = Zend Framework DB

Trace = No

Server = 192.168.35.1

Port = 1433

Database = ZendFramework

TDS_Version = 8.0



########################################################################
############



[root@localhost html]# cat /etc/odbcinst.ini

[FreeTDS]

Description = v0.64 with protocol v8.0

Driver = /usr/local/lib/libtdsodbc.so

UsageCount = 1



[ODBC]

TraceFile = /tmp/sql.log

Trace = Yes



########################################################################
############

[root@localhost html]# cat /var/www/html/test.php

<?php

$connect = odbc_connect("MSSQLTestServer", "sa", "sa123");



$query = "SELECT * FROM xpto";



$result = odbc_exec($connect, $query);

while(odbc_fetch_row($result)) {

$field1 = odbc_result($result, 1);

$field2 = odbc_result($result, 2);

print("$field1 $field2\n");

}

odbc_close($connect);

?>



########################################################################
############



[root@localhost html]# php test.php

1 a

2 b

3 c



########################################################################
############



[root@localhost html]# cat /tmp/sql.log

[ODBC][2878][__handles.c][444]

Exit:[SQL_SUCCESS]

Environment = 0x9160ef0

[ODBC][2878][SQLAllocHandle.c][345]

Entry:

Handle Type = 2

Input Handle = 0x9160ef0

[ODBC][2878][SQLAllocHandle.c][463]

Exit:[SQL_SUCCESS]

Output Handle = 0x915c1c8

[ODBC][2878][SQLConnect.c][3549]

Entry:

Connection = 0x915c1c8

Server Name = [MSSQLTestServer][length = 15
(SQL_NTS)]

User Name = [sa][length = 2 (SQL_NTS)]

Authentication = [*****][length = 5 (SQL_NTS)]

UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE
'UCS-2LE'



[ODBC][2878][SQLConnect.c][4123]

Exit:[SQL_SUCCESS]



...





########################################################################
############



[root@localhost html]# wget http://localhost/test.php



########################################################################
############



[root@localhost html]# cat /tmp/sql.log

[ODBC][2804][__handles.c][444]

Exit:[SQL_SUCCESS]

Environment = 0x942f4d0

[ODBC][2804][SQLAllocHandle.c][345]

Entry:

Handle Type = 2

Input Handle = 0x942f4d0

[ODBC][2804][SQLAllocHandle.c][463]

Exit:[SQL_SUCCESS]

Output Handle = 0x942ce48

[ODBC][2804][SQLConnect.c][3549]

Entry:

Connection = 0x942ce48

Server Name = [MSSQLTestServer][length = 15
(SQL_NTS)]

User Name = [sa][length = 2 (SQL_NTS)]

Authentication = [*****][length = 5 (SQL_NTS)]

UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE
'UCS-2LE'



DIAG [08S01] [FreeTDS][SQL Server]Server is unavailable
or does not exist.



DIAG [S1000] [FreeTDS][SQL Server]Unable to connect to
data source



[ODBC][2804][SQLConnect.c][3917]

Exit:[SQL_ERROR]

[ODBC][2804][SQLError.c][424]

Entry:

Connection = 0x942ce48

SQLState = 0xbfb11242

Native = 0xbfb1103c

Message Text = 0xbfb11042

Buffer Length = 511

Text Len Ptr = 0xbfb11040

[ODBC][2804][SQLError.c][461]

Exit:[SQL_SUCCESS]

SQLState = S1000

Native = 0xbfb1103c -> 0

Message Text = [[unixODBC][FreeTDS][SQL
Server]Unable to connect to data source]

[ODBC][2804][SQLFreeHandle.c][268]

Entry:

Handle Type = 2

Input Handle = 0x942ce48

[ODBC][2804][SQLFreeHandle.c][317]

Exit:[SQL_SUCCESS]







Archive powered by MHonArc 2.6.24.

Top of Page