Can anybody work out why this is returning an error?

Hi there,

I’m pulling my hair out with this one. When this mail script is run (actioned from a seperate form), the mail appears to be sent fine but the HTML wont display because the script causes an internal error:

malformed header from script. Bad header=/home/sites/e***ign.: confirm.php, referer: http://www.educationaldesign.co.uk/school_enquiry.php

Can anybody see why the header is being corrupted?
Here’s the code:

[code]<?php
ini_set(‘arg_separator.output’,’&’);

$enq=$_POST[‘enquiry_type’];
$name=$_POST[‘name’];
$org=$_POST[‘organisation’];
$sch=$_POST[‘school’];
$lea=$_POST[‘lea’];
$email=$_POST[‘email’];
$tel=$_POST[‘tel’];
$fax=$_POST[‘fax’];
$prod=$_POST[‘product’];
$msg=$_POST[‘msg’];
$pcms=$_POST[‘primary_cms’];
$scms=$_POST[‘secondary_cms’];

$body= “Dear {$name}, nThank you for your enquiry. nYour message has been received by the Educational Web Design team. nYou sould receive a responce within the next 48 hours.nnEducational Web Design.”;
mail($email, ‘Thank you for your Enquiry’, $body, ‘From: info@e*******.co.uk’);

mail(‘info@*******.co.uk’,

/* Subject */ ‘Educational Web Design - Web Enquiry’,

"Enquiry Type: {$enq}n
Name: {$name}n
Organisation: {$org}n
School:{$sch}n
LEA: {$lea}n
Email: {$email}n
Telephone: {$tel}n
Fax: {$fax}n
Product: {$prod}n
Message: {$msg}n
Primary CMS Demo: {$pcms}n
Secondary CMS Demo: {$scms}n
",

“From: {$email}”);

?>

   <html xmlns="http://www.w3.org/1999/xhtml"
         xml:lang="en">
School Contact ...... [/code]

http://tinyurl.com/2wkhe3

Looks like the problem isn’t PHP-specific, but rather CGI-specific (and that tells me that your PHP runs as a CGI app). But the solution … I dunno ^_^;;

Admin Edit: Shortened URL using Tinyurl.com to avoid screen scrolling from left to right

Thanks Zyppora,

I think you got it! I know this script is valid as I had it working on a previous server no problem. I also had other people test it. I have migrated to a new hosting provider and they insist on running php as cgi. So I am convinced it is a cgi problem and nothing to do with the PHP.

Does anyone have an idea to a solution? If this turns out to be a cgi issue it could cause problems with any script. I need to find out how to get around it.

Anybody out there have any clues???

Heheh, I guess the easiest answer to that (and the least desired) would be: put this problem in an email and send it to your host :) I’m pretty sure they know how to fix it, if they have a strong preference for running PHP as a CGI app.

That’s an enlightened suggestion. And funnily, the very first thing I did.
However, hosting companies being as they are don’t like giving support for third-part scripts. they want you to use theirs. So their answer is don’t use your scripts use ours - they work!

Just thought (was quite sure actually) there might be somebody in this PHP help forum who may have more knowledge of php than me and know something about the issues of php as cgi…?

Well, I’m not a pro when it comes to CGI, but perhaps it’s possible for you to use the host’s PHP scripts and view the source code? Perhaps you can study the differences between your script and theirs to fix whatever’s wrong with yours :slight_smile:

Thanks for that Zyppora,

And if worse comes to worst, just tell your host that YOU wrote that script, so it could never be 'third-party'

Excellent suggestion! Might just do that. Thanks.

I would be curious as to your solution also…
Is this an IIS server? or Apache?

Sponsor our Newsletter | Privacy Policy | Terms of Service