I'm experiencing a 500, Internal Server error on my website. The error logs show the following error: "Premature end of script headers: cgi_wrapper", in my Joomla application.
It only occurs when one particular file is loaded. The rest of the application/website works as it should. There are no other related issues that show up in the error logs - no indication of a timeout or a permissions error.
The file that is causing the error is a template/layout file. Furthermore, I have identified a snippet of code that will cause the error, when this is commented out, the site loads just fine. Here it is:
if( $question->type == '1' || $question->type == '2' || $question->type == '3' )
{
//shuffle items
$shuffled_items = $this->shuffle_assoc($items);
$output = '';
$output .= '<table class="answer-table">';
$output .= '<tr>';
$output .= '<td>';
$output .= '<ul class="answers">';
foreach($shuffled_items as $item)
{
$output .= '<li num=' . $item->num . '>';
$output .= $item->item;
$output .= '</li>';
}
$output .= '</ul>';
$output .= '</td>';
$output .= '</tr>';
$output .= '</table>';
$output .= '<table class="answer-table correct-answer" style="display: none">';
$output .= '<tr>';
$output .= '<td>';
$output .= '<p class="question-instructions">Correct Answer:</p>';
$output .= '<ul class="answers correct-answer">';
foreach($items as $item)
{
$output .= '<li num=' . $item->num . '>';
$output .= $item->item;
$output .= '</li>';
}
$output .= '</ul>';
$output .= '</td>';
$output .= '</table>';
echo $output;
}
It uses a variable, $questions, that is set in the view.html.php file (for those who know Joomla). It is this variable that seems to be triggering the error. If I don't assign the $questions variable, then the template will load just fine.
Also, in the example above, it first tests the question type ($question->type). There are other sections of code that would be triggered, and still produce the error, if $question->type is not 1, 2, or 3. But I left out the other code for brevity, and because it only gets called when the relevant question type exists. When the code above alone gets run, it causes the error.
So, I'm lost here. What baffles me is that only this template file, and the $questions variable causes the error. Everything else works fine. It also runs fine on my local server.
Almost forgot, using Joomla 1.5.22, PHP 5.3.3, Apache 2.2.3, Cent OS 5.8. The server also runs Parallels Plesk Panel 10.
I hope someone can point me to a solution.
Thanks!