Connecting Tech Pros Worldwide Help | Site Map

Header Question

mtek@mtekusa.com
Guest
 
Posts: n/a
#1: Mar 26 '08
Hi,

I have a PHP script which performs some processing. And, when that is
done, I want to use the 'header' command to load a different page.

I read that this command must be the first in the script, before
anything else is put to the screen. I have a bunch of coding to
define variables and store them in a MySQL database, but nothing goes
to the screen.

After I perform all my processing, I put the header command in and all
I get is a blank screen?? If I put the command at the top of the
file, it works fine. The problem is, I have conditional statements in
this script, which will load different pages depending on the
condition met:

if (some condition) {
load page 1
} else {
load page 2
}

If hte header must be the first line, how can I accomplish this?

Thanks!

John
Martin
Guest
 
Posts: n/a
#2: Mar 26 '08

re: Header Question


On Tue, 25 Mar 2008 20:13:33 -0700 (PDT), mtek@mtekusa.com wrote:
Quote:
>Hi,
>
>I have a PHP script which performs some processing. And, when that is
>done, I want to use the 'header' command to load a different page.
>
>I read that this command must be the first in the script, before
>anything else is put to the screen. I have a bunch of coding to
>define variables and store them in a MySQL database, but nothing goes
>to the screen.
>
>After I perform all my processing, I put the header command in and all
>I get is a blank screen?? If I put the command at the top of the
>file, it works fine. The problem is, I have conditional statements in
>this script, which will load different pages depending on the
>condition met:
>
>if (some condition) {
load page 1
>} else {
load page 2
>}
>
>If hte header must be the first line, how can I accomplish this?
>
>Thanks!
>
>John
It doesn't have to be the first thing in your script but it does have
to be the first thing that is served out. I have a couple of scripts
where the header is 25-30 lines down in the script; but, it's the
first thing that the script sends out

Check your script. You must have something being served out prior to
your header. Maybe something in an included file that's at the top of
your script?


Guillaume
Guest
 
Posts: n/a
#3: Mar 26 '08

re: Header Question


mtek@mtekusa.com a écrit :
Quote:
Quote:
Quote:
>>>Just ensure you have no space before or after the braces in the included
>>>file. ANY output - even white space - will cause headers to be sent
>>>and, as a result, the header() call to fail.
[...]
Quote:
What do you suggest to solve the issues?
Exactly what he said above, there is really no need for ob_* functions
when you can just pay attention (and possibly activate errors display).

--
Guillaume
Closed Thread