Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!


I also asked this on stackoverflow 12 days ago, but so far no response. Maybe it is more appropriate here at serverfault.

share|improve this question
    
The error log of apache server should indicate the type of error. The error 500 is a general error. You need to know the specific error type to fix it. –  Khaled Dec 29 '12 at 7:22
    
Thanks for the reply. The error log doesn't specify what caused the error. Only the 'premature end..." error and sometimes the file the caused the error is also specified. –  Ron Dec 29 '12 at 7:47
1  
Premature end of script headers means there was an error in the CGI/FastCGI script that Apache called. You need to check your PHP error logs, not your Apache error logs. –  Michael Hampton Dec 29 '12 at 16:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.