By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

Header() issue..

P: n/a
Hello everyone, im trying to connect to a database, and depending on some of
the variables determine where to redirect the page to.

However im sure I am not grasping the concept of header(location: url) to
the fullest.
And I keept getting the dreaded:

Warning: Cannot add header information - headers already sent by (output
started by file.php) on line <line ##>.

error, so could someone let me know if there is another way to redirect this
page using PHP, basically of the variable == 1 it goes to pagea.php, if the
variable ==2 it goes to pageb.php

Pretty straight forward, and the SQL is all set up properly, just need to
forward this.

Thanks!
Jul 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Tuesday 26 of August 2003 22:20, Adam wrote in comp.lang.php:

Warning: Cannot add header information - headers already sent by (output
started by file.php) on line <line ##>.


Headers need to be the _first_ output of PHP script - even the PHP
warning/error messages matter!! So, check if something didn't produce the
output (it actually did ;) before ...

regards!

-robert-

--
Robert Jirik
[mailto:robert(at)aristoteles(dot)xhaven(dot)net]
public PGP key: http://xhaven.net/robert/pgp_key.asc
-
He means well' is useless unless he does well
-- Plautus

Jul 16 '05 #2

P: n/a
I forgot to mention that there is an include file on line 1.
And that pages does produce output, is there a way around that??

Thanks for the quick reply!
"Robert Jirik" <ro****@aristoteles.xhaven.net> wrote in message
news:bi***********@news.nextra.cz...
Tuesday 26 of August 2003 22:20, Adam wrote in comp.lang.php:

Warning: Cannot add header information - headers already sent by (output
started by file.php) on line <line ##>.


Headers need to be the _first_ output of PHP script - even the PHP
warning/error messages matter!! So, check if something didn't produce the
output (it actually did ;) before ...

regards!

-robert-

--
Robert Jirik
[mailto:robert(at)aristoteles(dot)xhaven(dot)net]
public PGP key: http://xhaven.net/robert/pgp_key.asc
-
He means well' is useless unless he does well
-- Plautus

Jul 16 '05 #3

P: n/a
Adam wrote:
I forgot to mention that there is an include file on line 1.
And that pages does produce output, is there a way around that??

Thanks for the quick reply!


If you have the relevant version of PHP, and it's not been disabled in the
server config, you can put

ob_start();

at the beginning of the code, before any output takes place. That will
let you spit headers out right at the end of the script if you want!

There's more info on this kind of thing at
http://www.php.net/manual/en/ref.outcontrol.php

Jul 16 '05 #4

P: n/a
Thanks Matty, ill get looking at that right away!

"matty" <ma*******@askmenoquestions.co.uk> wrote in message
news:Jm*************@wards.force9.net...
Adam wrote:
I forgot to mention that there is an include file on line 1.
And that pages does produce output, is there a way around that??

Thanks for the quick reply!


If you have the relevant version of PHP, and it's not been disabled in the
server config, you can put

ob_start();

at the beginning of the code, before any output takes place. That will
let you spit headers out right at the end of the script if you want!

There's more info on this kind of thing at
http://www.php.net/manual/en/ref.outcontrol.php

Jul 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.