/    Sign up×
Community /Pin to ProfileBookmark

header:location not working on server

Hi,

I’ve been adapting some code for someone, and it works fine on both my testing server and on my own server, but I’ve just uploaded it to their server, and all the header: location commands just aren’t working.

for example

[code]header(“Location: bid-confirm.php?$pre_auth”);[/code]

just does nothing at all on their server, but works absolutely fine on mine.

Any ideas?

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJul 23.2008 — Not really enough info to suggest a definite cause to your problem. I'd suggest 2 things, though. Add the following for now to make sure you're seeing all error messages:
[code=php]
<?php
ini_set('display_errors', 1); // change to 0 for production version
error_reporting(E_ALL);
[/code]

Also, to be HTTP/1.1 compatible, the location header should use a full URL:
[code=php]
header("Location: http://www.example.com/bid-confirm.php?$pre_auth");
[/code]

Also, what is the value of $pre_auth? Does it need to be [url=http://www.php.net/urlencode]urlencode[/url]()-ed?
Copy linkTweet thisAlerts:
@mistafeeshauthorJul 24.2008 — Thanks for your suggestions. Unfortunately I'm still stumped!

It doesn't report any errors or even try to go to the address. I tried adding the site root to the code, but to no avail. Wierd!

$pre_auth is a string of letters and number such as "2938171938095165ac3bbcc312f4805e"

The address stays the same, with the page source totally blank (ie nothing makes it as far as the browser)
Copy linkTweet thisAlerts:
@NogDogJul 24.2008 — Sounds like a parse error somewhere in the script. If the system setting for display_errors is off, you won't see any errors even if you turn it on in your script, as parse errors occur before any commands are actually executed.
Copy linkTweet thisAlerts:
@mistafeeshauthorJul 24.2008 — Thanks. It was a little bit of blank space in the database definition file after the end of the php code - my server was less fussy about it, and of course, error reporting was turned off!
Copy linkTweet thisAlerts:
@FrankTheTankJul 25.2008 — You never want whitespace at the end of your php files... I have yet to learn why, but every so often, it causes strange errors.

Frank
Copy linkTweet thisAlerts:
@mistafeeshauthorJul 25.2008 — Yeah - a lesson learned the hard way for me!
Copy linkTweet thisAlerts:
@TheGameJul 25.2008 — eliminate all "echo" word in the page
Copy linkTweet thisAlerts:
@SyCoJul 25.2008 — eliminate all "echo" word in the page[/QUOTE]
That wont help track down errors for headers. It's not just echo but output

eg this will break.

<?

?>

<?

//header here

?>

mistafeesh, glad you sorted it. Blank spaces can suuuuuk. I once was working on a heavily indented piece of code which was throwing a parse error even when commented out. I was pulling my hair out. Turned out to be a backtick got added when tabbing and I totally missed it due to the indents. We screw up, we learn. We screw up less!
×

Success!

Help @mistafeesh 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...