Jump to content

Recommended Posts

Hi,

 

I don't have much experience with PHP, but I have to set up an existing PHP site in a new test environment.

 

The website is working correctly in its original environment, but not in the test environment.

On some pages, a 500 error is returned.

 

 

After some debugging, I found that the source of this error is a line calling the preg_match_all function to parse a rather (32k) html/javascript page.

 

This happens because this is the way the site is built. Javascript/PHP/HTML content is fetched from the DB and is being parsed and merged.

 

In some of the loaded content, that's being parsed, there must be a problem with structure and/or size, causing the preg_match_all to throw StackOverflow.

 

The environments are quite different:

 

Working:

IIS7

WinSrv2008

CGI

 

Testing (not completely working)

IIS6

FastCGI

WinSrv 2003

 

Still, I should be able to manage to set up the site correctly, preferably without changing too much code.

 

So I'm hoping that there might exist a setting or other configuration property that might fix/workaround/catch this issue...

 

Any ideas?

a new test environment

 

Set error_reporting to E_ALL and display_errors to ON in your master php.ini. Stop and start the IIS service to get any change made to the master php.ini to take effect and use a phpinfo() statement to confirm that the two settings were changed.

 

This will cause all php errors to be reported and displayed, which will likely tell you why the code is failing. No guessing is necessary.

Hi PFMaBiSmAd, Thanks for the answer.

 

I've changed the settings as you said.

 

I get loads and loads of PHP Notices per request now, but no more errors...

 

phpinfo() says:

 

error_reporting 6143 6143

display_errors    On         On

 

 

Notices are:

- Undefined variable

- Undefined offset

- Undefined index

 

 

 

A) All of those notice messages are slowing down the execution of your code because php must still handle each one and try to figure out what to do with it even if they are hidden by the error_reporting/display_errors settings and if log_errors is ON you are continually adding to your error log file, and

 

B) one or more of them are probably pointing to the area in the code that is not working that is causing the 500 page error (which basically means that the web server did not output a complete response.)

 

Code should not normally generate any php errors when it executes so that real errors that do occur can be found.

 

I would find and fix the problem causing each error.

 

If You find that some of the undefined errors are due to program variables that are no longer set from external data or session data, then you have a register_globals problem in the code that needs to be fixed (register_globals have been completely removed in php6, so that turning on the setting is just a short term fix.)

Hi thanks again for that answer.

 

Well, that the code isn't very well written, that's no suprise :). I didn't write it and am normally a .NET developer, so PHP is pretty new to me, but it doesn't take a genius to see the problems in maintainability etc in that code :)...

 

I'll have a look at what you are saying tommorrow, but I still find it strange that an exact copy of DB + code won't run correctly on another environment.

 

Actually, I don't really find it strange, but rather annoying that apparently a simple setting can't fix this problem...

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.