djclaux Posted August 17, 2009 Share Posted August 17, 2009 Hi everybody, I am migranting a website from php4/Win 2000 Server to php5/Win 2003 Server. Using the IIS as webserver. The website has 2 parts: 1) Some feeding and cleaning database processes that are scheduled to run using the schedule task tool. For this i use the php-cgi.exe executable with the -f option (filepath). 2) The admistrative and user interface (Normal website) working in IIS 6.0. Both parts share alot of classes and code functions and variable initializations. But i have notice that some tasks stop working in PHP5. After some debbuging i found the problema was related to the MS SQL connection: The mssql_connection() code get allways a can't connect to the database error when running as a task but works fine when executing in a browser context (IIS). To test this i have done a small program that get completly diferent results when running as a task or as a php webpage: if ($con = mssql_pconnect("SERVER","USER","PASSWORD")){ print("YES");} else{ print("NO")} Outputs "YES" in the browser but a "Warning: mssql_pconnect(): Unable to connect to server: SERVER in PATH_TO_SCRIPT on line codeline" in the task The connection strings are 100% correct. More interesting is that i have found that if i use the odbc_connect() function it works just fine for both task and browser: if ($con = odbc_connect("Driver={SQL Server};Server=SERVER;Database=DB;","USER","PASSOWORD")){ print("YES");} else{ print("NO")} => Works allways well!!! The problem is that tasks and website share alot of code, and changing from mssql_connect to odbc_connect is not something to do ligthly. Question: Why the mssql_connect stopped to work? Does anyone get this type of problem? What could be the problem? Some help appreciatted! My configuration Info: PHP-5.2.9-2 MS SQL SERVER SQL Server Enterprise Edition 8.00.2184(SP4) Microsoft Windows NT - 5.0(2195) Windows Server: MS Windows Server 2003 R2 SP2 php.ini [MSSQL] mssql.allow_persistent = On mssql.max_persistent = -1 mssql.max_links = -1 mssql.min_error_severity = 10 mssql.min_message_severity = 10 mssql.compatability_mode = Off thanks for your help, and sorry if my english are not mutch of a perfection... Claudio Link to comment https://forums.phpfreaks.com/topic/170655-mssql_connect-problems-only-in-a-schedule-task-context/ Share on other sites More sharing options...
corbin Posted August 17, 2009 Share Posted August 17, 2009 Is PHP using the same ini in both cases? Also, I don't think this is the problem, but when running CLI scripts, you should use php.exe, not php-cgi.exe since php-cgi is made for PHP used in a CGI context. Also, it might be worth a try to use mssql_connect instead of pconnect. Link to comment https://forums.phpfreaks.com/topic/170655-mssql_connect-problems-only-in-a-schedule-task-context/#findComment-900333 Share on other sites More sharing options...
djclaux Posted August 18, 2009 Author Share Posted August 18, 2009 Yes the ini file is the same. I try with connect and pconnect. I also try php.exe and php-win.exe e non works Link to comment https://forums.phpfreaks.com/topic/170655-mssql_connect-problems-only-in-a-schedule-task-context/#findComment-900769 Share on other sites More sharing options...
djclaux Posted August 18, 2009 Author Share Posted August 18, 2009 Problem solved! I upgrade the ntwdblib.dll lib (http://www.dlldll.com/ntwdblib.dll_download.html) to the 2000.80.194.0 version and it starts to work fine thanks Link to comment https://forums.phpfreaks.com/topic/170655-mssql_connect-problems-only-in-a-schedule-task-context/#findComment-900997 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.