#21928 [Opn->Fbk]: Cannot find valid ODBC DSN

From: Date: Wed, 29 Jan 2003 22:49:35 +0000
Subject: #21928 [Opn->Fbk]: Cannot find valid ODBC DSN
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-31632@lists.php.net to get a copy of this message
ID: 21928 Updated by: pollita@php.net Reported By: Matt.hintze@nana.com -Status: Open +Status: Feedback Bug Type: ODBC related Operating System: Win2k server PHP Version: 4.3.0 New Comment: Um.... you issue an odbc_connect() call that you know will fail, then try to pass the result (which is === FALSE by the way) to commands which expect a valid resource and you're somehow SURPRISED by the results you got? Ignoring that walking contradiction for the moment.... The fact that it's happening on IIS only (and not command line) suggests one of three posssible explanations: (A) It's a User DSN created by your user account (hence visible to you on the command line but not to the webserver who is running as IUSER_GUEST or whatever) (yes I know you said it was system, but please, check again as this is the most likely answer) Just for giggles, try logging in as another user (non-administrator though) and trying that sample script I provided earlier on the command line. (B) There are one or more files (odbc.dlls) which are unreadable/unexecutable by the IIS user (not terribly common, but at least possible -- are you in the administrator group?) (C) You're connecting to an ODBC datasource which requires built in NT authentication (such as MSSQL) and you have no IUSR_GUEST account on the SQL server which is somehow throwing an incorrect error message. (highly bloody unlikely) Previous Comments: ------------------------------------------------------------------------ [2003-01-29 12:23:53] Matt.hintze@nana.com This is what I ran from IIS <? $dbh = odbc_connect(); // yes I know it will fail $res = odbc_data_source($dbh, SQL_FETCH_FIRST); echo $res; $res = odbc_data_source($dbh, SQL_FETCH_NEXT); echo $res; ?> These are the results. Warning: Wrong parameter count for odbc_connect() in c:\inetpub\wwwroot\survey\test.php on line 3 Warning: odbc_data_source(): supplied argument is not a valid ODBC-Link resource in c:\inetpub\wwwroot\survey\test.php on line 4 Warning: odbc_data_source(): supplied argument is not a valid ODBC-Link resource in c:\inetpub\wwwroot\survey\test.php on line 6 ------------------------------------------------------------------------ [2003-01-29 07:19:09] kalowsky@php.net kept as feedback until testing done... ------------------------------------------------------------------------ [2003-01-29 00:29:25] Matt.hintze@nana.com BTW: I am running MDAC 2.7 SP1 ------------------------------------------------------------------------ [2003-01-29 00:27:09] Matt.hintze@nana.com I'll run your test in the morning. It might be notable that I can run my script from the command line and have no problems connecting to the ODBC DSN. But when I run it through IIS, it fails. I ran this same script on my local win2k pro desktop and it works fine. This is only happening on my win2k server. I searched the net and see lots of people with this same issue, but cannot find a single one that has a resolution. ------------------------------------------------------------------------ [2003-01-28 22:40:06] kalowsky@php.net I don't believe this is a PHP bug itself at all. First off what version of the MDAC are you using? Second can you try doing the following: $dbh = odbc_connect(); // yes I know it will fail $res = odbc_data_source($dbh, SQL_FETCH_FIRST); And print out the results of the $res, and call the data_source() a few more times with SQL_FETCH_NEXT instead of SQL_FETCH_FIRST? Thanks ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/21928 -- Edit this bug report at http://bugs.php.net/?id=21928&edit=1

« previous php.bugs (#31632) next »