LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Content-type header in php missing (http://www.linuxquestions.org/questions/linux-server-73/content-type-header-in-php-missing-536626/)

xlq 03-11-2007 04:33 PM

Content-type header in php missing
 
I'm trying to use php under Apache 1.3, Slackware 11. Perl/CGI is working fine but when I run a PHP script, I get the 'premature header' error which means neither PHP nor Apache is generating the Content-type header. It works if I put the header line 'Content-type: text/html' right at the top of the PHP script, which is not what I thought I was supposed to do. I've searched php.ini and httpd.conf and Google but I can't find out where the header is supposed to be generated in php.

Where do I configure PHP or Apache to generate the content-type header?

rch1231 03-14-2007 12:36 AM

Try adding the following lines above your php entries or creating a header.php file that you include in your code:

<html>
<head>
<title>Page Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
</head>
<body>

<?php (your code goes here) ?>

The entry to call your header.php every time is:

<?php include ("header.php") ?>

xlq 03-15-2007 08:06 AM

I found the problem! I had ScriptAlias set for the php directory, which tried to execute the php file. I unset ScriptAlias, and it all works fine.


All times are GMT -5. The time now is 12:22 AM.