Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-05-2012, 07:53 PM   PM User | #1
Blockis
New Coder

 
Join Date: Sep 2009
Posts: 36
Thanks: 4
Thanked 0 Times in 0 Posts
Blockis is an unknown quantity at this point
Header Redirect [Simple]

I know this is pathetic, but it's kicking my *** right now. All I want is a simple redirect.

PHP Code:
<?php
header
("Location: http://www.google.com/"); /* Redirect browser */

/* Make sure that code below does not get executed when we redirect. */
exit;
?>
And yet it renders the:
Code:
Warning: Cannot modify header information - headers already sent by (output started at /home/paul/public_html/x.php:1) in /home/paul/public_html/x.php on line 2
error.

What combination of ob_start or ob_flush commands do I need to do to get this to work??
Blockis is offline   Reply With Quote
Old 06-05-2012, 07:58 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
What you have there should work ...
if you have no other code before that example you've shown.

Even if you have blank lines before <?php ... that will cause the error.

Make sure <?php is on the very top line.
mlseim is offline   Reply With Quote
Old 06-05-2012, 08:05 PM   PM User | #3
Blockis
New Coder

 
Join Date: Sep 2009
Posts: 36
Thanks: 4
Thanked 0 Times in 0 Posts
Blockis is an unknown quantity at this point
Yeah, I'm only using it to redirect...

http://affiliatestoolbox.com/pkm/grocery2.php

I tried FF and Chrome, with both having the same problem.

I'm completely lost, as this is the simplest thing, yet frustrating me the most, lol.
Blockis is offline   Reply With Quote
Old 06-05-2012, 08:45 PM   PM User | #4
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
You're running that redirect just like you've shown?
You're not including it in another script are you?
mlseim is offline   Reply With Quote
Users who have thanked mlseim for this post:
Blockis (06-05-2012)
Old 06-05-2012, 09:00 PM   PM User | #5
Blockis
New Coder

 
Join Date: Sep 2009
Posts: 36
Thanks: 4
Thanked 0 Times in 0 Posts
Blockis is an unknown quantity at this point
No, but tango helped me out. Thanks though!
Blockis is offline   Reply With Quote
Old 06-05-2012, 09:22 PM   PM User | #6
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Let us know what it was ... I'm curious.
mlseim is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:57 PM.


Advertisement
Log in to turn off these ads.