Jump to content

Recommended Posts

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

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.