/    Sign up×
Community /Pin to ProfileBookmark

Throwing internal server error when header is changed

Hello,

I am using this script:

<?php
$answer = $_REQUEST[‘answer’] ;

$correctanswer = “ANSWER”;

$lasttaskloc = “http://www.example.com/wrong/“;

$nexttaskloc = “http://www.example.com/right“;

if (answer == correctanswer) {
header(nexttaskloc);
} else {
header(lasttaskloc);
}

?>

However, when I run this, the page shows a 500 internal server error.

I checked my server logs and I got this error:

[Fri Aug 28 20:23:44 2009] [error] [client 86.161.50.191] FastCGI: comm with server “/var/www/fcgi/php-cgi” aborted: error parsing headers: malformed header ‘lasttaskloc’

Any one know how to fix this?

Thank you very much for your help,

Sam

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@criterion9Aug 28.2009 — The "header" function in php sends new header information to the browser. If you are trying to change the "Location: " header you will need to include that in the function call:
[code=php]
header("Location: your_location_here");
[/code]


php.net/header
×

Success!

Help @samiles spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...