[freetds] PHP 5.2.6 + pdo_dblib + FreeTDS 0.64 -- tds_open_socket: Unknown error: 0

Kian Mohageri kian.mohageri at gmail.com
Wed Jul 23 19:27:27 EDT 2008


This began after an upgrade to FreeBSD 7.0.  I've been trying to track
it down for a while now.

The strange thing is that the same exact script works fine via the
Apache module, just not the command line.  There are no special
environment variables set in Apache.

$dbh = new PDO('dblib:host=foobar;dbname=foobar', 'user', 'pass');

foreach($dbh->query('SELECT TOP 10 ID_Number, Plan_ID FROM
av_user_pcs_Patron') as $row) {
        print_r($row);
}


I tried to figure this out the best I could, but I'm all out of ideas.

I'm still waiting for 0.82 to hit the ports tree...

Any help would be greatly appreciated.  If this is something more
appropriate to post to PHP or FreeBSD, I apologize.

-Kian

[foobar]
        host = foobar.housing.wwu.edu
        port = 2638
        tds version = 5.0


$ env TDSDUMPCONFIG=stdout TDSDUMP=stdout php testpdo.php
util.c:288:Starting log file for FreeTDS 0.64
        on 2008-07-23 16:21:00 with debug flags 0x4fff.
config.c:158:Attempting to read conf files.
config.c:259:...$FREETDSCONF not set.  Trying $FREETDS/etc.
config.c:275:...$FREETDS not set.  Trying $HOME.
config.c:202:Found conf file '/usr/local/etc/freetds.conf' (default).
Reading section 'foobar'.
config.c:333:Looking for section global.
config.c:390:... Found section global.
config.c:393:Got a match.
config.c:413:option = 'tds version' value = '4.2'.
config.c:413:option = 'dump file' value = '/tmp/freetds.log'.
config.c:413:option = 'debug flags' value = '0xffff'.
config.c:390:... Found section foobar.
config.c:390:... Found section jdbc.
config.c:390:... Found section jdbc_42.
config.c:390:... Found section mypool.
config.c:333:Looking for section foobar.
config.c:390:... Found section global.
config.c:390:... Found section foobar.
config.c:393:Got a match.
config.c:413:option = 'host' value = 'foobar.housing.wwu.edu'.
config.c:440:Found host entry foobar.housing.wwu.edu.
config.c:443:IP addr is 140.160.12.123.
config.c:413:option = 'port' value = '2638'.
config.c:413:option = 'tds version' value = '5.0'.
config.c:390:... Found section jdbc.
config.c:390:... Found section jdbc_42.
config.c:390:... Found section mypool.
config.c:206:...Success.
config.c:578:Setting 'dump_file' to 'stdout' from $TDSDUMP.
16:21:00.281636 37177 (util.c:288):Starting log file for FreeTDS 0.64
        on 2008-07-23 16:21:00 with debug flags 0xffff.
16:21:00.281760 37177 (iconv.c:195):names for ISO-8859-1: ISO-8859-1
16:21:00.281795 37177 (iconv.c:195):names for UTF-8: UTF-8
16:21:00.281814 37177 (iconv.c:195):names for UCS-2LE: UCS-2LE
16:21:00.281829 37177 (iconv.c:195):names for UCS-2BE: UCS-2BE
16:21:00.281841 37177 (iconv.c:361):iconv to convert client-side data
to the "ISO-8859-1" character set
16:21:00.281866 37177 (iconv.c:514):tds_iconv_info_init: converting
"ISO-8859-1"->"UCS-2LE"
16:21:00.281944 37177 (net.c:168):Connecting to 140.160.12.123 port 2638.
16:21:00.282174 37177 (net.c:237):tds_open_socket:
140.160.12.123:2638: Unknown error: 0
16:21:00.282304 37177 (util.c:119):Changing query state from IDLE to DEAD
16:21:00.282461 37177 (token.c:2252):tds_client_msg: #20009: "Server
is unavailable or does not exist.".  Connection state is now 4.
16:21:00.282638 37177 (mem.c:519):tds_free_all_results()
16:21:00.282800 37177 (dblib.c:4978):in dbfreebuf()

Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[HY000] Server is unavailable or does not exist. (severity
9)' in /usr/home/kian/public_html/testpdo.php:3
Stack trace:
#0 /usr/home/kian/public_html/testpdo.php(3):
PDO->__construct('dblib:host=foob...', 'user', 'pass')
#1 {main}
  thrown in /usr/home/kian/public_html/testpdo.php on line 3
16:21:00.283745 37177 (ct.c:241):ct_exit()



More information about the FreeTDS mailing list