LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   php script: Premature end of script headers (https://www.linuxquestions.org/questions/programming-9/php-script-premature-end-of-script-headers-563248/)

Zeno McDohl 06-20-2007 12:37 PM

php script: Premature end of script headers
 
I have this in file called test.php:
Code:

<html>

<head>
<title>Test PHP Script date!</title>
</head>
<? print(Date("l F d, Y")); ?>

<body>
</body>
</html>

When I try to access it via the web, I get an Internal Server Error. The error_log reports:
Quote:

Premature end of script headers: /public_html/data/test.php
Any idea what is wrong? This is on a linux server.

(If I move the file out of the data directory, it works fine)

Centinul 06-20-2007 09:09 PM

Have you tried this for a test?
Code:

<?php
phpinfo();
?>

Is your PHP configured for short tags as well? ( <? ?> )?

HTH,

Centinul

Zeno McDohl 06-21-2007 10:16 AM

Okay I tried that. I get the same exact error.

Centinul 06-21-2007 10:26 AM

Have you tried searching google for this error? In my brief research it appears the script dies before it sends anything to the web server and that is where the error arises.

I would imagine this problem must have happened to someone before so I would think you could find a solution on the net.

You mention that it works fine in another directory. Is that directory outside the web server's document root or not? What are the permissions of these two directories?

Thanks

Centinul

Zeno McDohl 06-21-2007 10:37 AM

Indeed, I tried Googling for the error but everything was about perl/cgi etc and not what I wanted.

No, the directory is still under the users account. data is simply a subdirectory. The permissions for data is drwxr-xr-x and for the main directory it's drwxr-x---

Centinul 06-21-2007 11:20 AM

Hmm...

Could you post your webserver and php configuration so we can take a look at it?

Thanks,

Centinul

Zeno McDohl 06-21-2007 01:26 PM

The entire php.ini? Or something else?

graemef 06-21-2007 07:44 PM

What are your file permissions on the data directory?

chrism01 06-22-2007 02:20 AM

iirc, 'premature end of header' usually means you've forgot that in HTML there have to be 2 (!) newline chars after the hdr, before the body.

Zeno McDohl 06-25-2007 10:26 AM

I figured it out. Turns out the data directory had the wrong user permissions. I had to chown and chgrp the directory and now it works fine.

I wish the error messages actually told me something useful. Maybe mention something about permissions. Sigh.


All times are GMT -5. The time now is 04:18 AM.