Skip to Content.
Sympa Menu

freetds - Re: [freetds] mssql_connect fails with PHP 4.3.4 on RH Linux 9

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Daniel Fazekas <fdsubs AT axelero.hu>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] mssql_connect fails with PHP 4.3.4 on RH Linux 9
  • Date: Thu, 4 Dec 2003 03:23:17 +0100

On Dec 4, 2003, at 2:03, James McGowan wrote:

Could you try a short test without Apache?

Just create a short .php script which doesn't assume it's a web page,
and test if from the command-line
php testscript.php
This should help narrow down the problem a lot.
I've already tested this using a one-line script, calling <?phpinfo()?>. This returns all of the PHP settings in non-html text, so the CGI mode of PHP works, running from root or as nobody. PHP runs "inside" Apache which runs as user nobody.

Ouch. I though it would be obvious enough that I was implying testing mssql connectivity. :)
It's nice to know that your php executable exists, but of course that's built by default now since 4.3.0 of PHP, in addition to the Apache module. It should actually be the "cli" SAPI version of PHP as opposed to the "cgi" version.

This would
- take Apache out of the equation for now
- definitely enable you to get the freetds logging work

You could just open your shell and type

TDSDUMP=freetds.log php testscript.php

..and you get that log file right there in the current working directory. You don't even need to change your freetds.conf file or any other configuration file.

Actually, I've been working on a little php test script today to help test your FreeTDS + PHP setup and help on the common problems I saw here.

It's not quite complete, but you can try it. I wasn't able to adequately test Sybase and ODBC today, but you are interested in MSSQL anyway.

Edit the first couple of lines in the attached php script, changing the
MSSQL_SERVER define to your server's entry in freetds.conf and setting MSSQL_USER and MSSQL_PASSWORD with the login information.

Then you could either load the script as served via Apache or run it from the command line.
See how far it gets. You could then just copy and paste the output to your reply. :)
There shouldn't be any new information there in your case, as we already know you use Linux, have Apache running as nobody, etc.

Run it from the command line with the debug log enabled as outlined above and attach it for all the freetds developers eager to analyze your problem. ;) What is "all kinds of junk" to you or myself could possibly tell others what the problem is.

(Note that while the script's output should not, the debug log might contain sensitive information such as your password. Check and remove that before submitting it.)


Or, it could be that the script - and the mssql connectivity - will run just fine from the command line, which is what I really wanted you to try all along. In that case we could start looking for the problem elsewhere, decidedly in your Apache installation or the PHP apache SAPI.

ps. Here's what my script outputs on this machine:
-------------
[fds@fdsmac Sites]$ TDSDUMP=tdsdump.log php freetds_test.php
PHP version: 4.3.4 (cli)
System uname: Darwin 7.0.0
Process UID/GID: 501:20 (fds:staff)
PHP configure command: './configure' '--prefix=/usr/local' '--mandir=/usr/local/share/man' '--infodir=/usr/local/share/info' '--with-config-file-path=/usr/local/etc' '--with-mssql=shared,/usr/local' '--with-mysql=/usr/local/mysql' '--with-iconv' '--with-readline' '--enable-exif' '--enable-ftp' '--enable-sockets' '--enable-shmop' '--enable-bcmath' '--enable-calendar' '--enable-sysvsem' '--enable-sysvshm' '--enable-wddx' '--enable-dbx' '--enable-dio' '--enable-trans-sid' '--enable-memory-limit' '--with-zlib' '--with-openssl' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-freetype-dir=/usr/local' '--with-t1lib' '--with-gd' '--with-kerberos=/usr' '--with-imap' '--with-imap-ssl' '--with-ldap=shared' '--with-ncurses=shared' '--with-curl=shared' '--with-zip=shared' '--with-mime-magic=shared' '--with-pdflib=shared,/sw' '--with-ming=shared,/sw' '--with-bz2=shared,/sw' '--with-pgsql' '--with-apxs'
FreeTDS-related PHP extension(s) loaded: mssql, odbc
FreeTDS-related environment variables:
TDSDUMP=tdsdump.log

MSSQL functions exist, testing connection: connected to server 'mssql'
Trying a test query: Microsoft SQL Server 2000 - 8.00.818 (Intel X86)
May 31 2003 16:08:15
Copyright (c) 1988-2003 Microsoft Corporation
Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 1)


ODBC functions exist, testing connection:
Warning: odbc_connect(): SQL error: [iODBC][Driver Manager]Driver's SQLAllocEnv() failed, SQL state IM004 in SQLConnect in /Users/fds/Sites/freetds_test.php on line 155
connection to server 'MSSQL' failed.
----------

Yes, as I noted my odbc definitely isn't working yet on the Mac... ;) I'll have to spend some more time on that.
It does work fine on my Linux box though.

--
fds


Archive powered by MHonArc 2.6.24.

Top of Page