I'm having the same problem, and it's annoying the heck out of me, DUDE! I keep getting this "500 Internal Server Error" in the browser and "Premature end to header scripts" error in the error log. I don't have much in my code except this at the beginning:
<? print("Content-type: text/html\n\n"); ?>
I have PHP 4.3 on a UNIX/FreeBSD using Apache2. I've installed Apache2, then PHP4. Since mine's on a UNIX system, I couldn't find much info other than for Windows systems through this site's Search.
If I run this script from the command-line, ie. "php test.php", it does not display any errors and executes the rest of the script as expected.
The php file is in a world-readable/executable directory. The file itself has been chmod'ed with execute permissions (755).
I've added these lines in Apache's httpd.conf file, according to the book "Essential PHP for:Web Professionals" by Christopher Cosentino:
ScriptAlias /php/ "/usr/www/php" # my php sandbox
AddType application/x-httpd-php .php
Action application/x-httpd-php "/usr/local/bin/php"
I've stopped and restarted the Apache server numerous times.
Anyone has ideas?