Fastcgi 500 error on preg_match_all in PHP
Posted
by Bertvan
on Stack Overflow
See other posts from Stack Overflow
or by Bertvan
Published on 2010-03-29T11:56:32Z
Indexed on
2010/03/29
12:13 UTC
Read the original article
Hit count: 295
Hi,
I'm trying to set up some exotic PHP code (I'm no expert), and I get a FastCGI Error 500 on a PHP line containing 'preg_match_all'.
When I comment out the line, the page is returned with a 200 (but not how it was meant to be).
The code is parsing php, html and javascript content loaded from the database and is composing them to return the finished page.
Now, by placing around some error_log entries I could determine that the line with the preg_match_all is the cause of the 500. However the line is hit multiple times during the loading of the page and on other occasions, the line does not cause an error.
Here's how it looks like exactly:
preg_match_all ("/(<([\w]+)[^>]*>)((?:.|\n)*)(<\/\\2>)/", $part['data'], $tags, PREG_PATTERN_ORDER|PREG_OFFSET_CAPTURE);
The subject string is a piece of text that looks like:
<script> ... some javascript functions ... </script>
[Edit:] This is code that is up and running correctly elsewhere, so this very well could be a PHP setting or environment difference. I'm using PHP 5.2.13 on IIS6 with FastCGI.
[Edit:] Nothing is mentioned in the log files. At least not in the ones I checked:
- IIS Logs
- Event Logs
- PHP Log
Any thoughts or direction would be welcome.
© Stack Overflow or respective owner