PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > Header Question
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Header Question

Réponse
 
LinkBack Outils de la discussion
Vieux 26/03/2008, 04h13   #1
mtek@mtekusa.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Header Question

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
  Réponse avec citation
Vieux 26/03/2008, 04h42   #2
Martin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Header Question

On Tue, 25 Mar 2008 20:13:33 -0700 (PDT), mtek@mtekusa.com wrote:

>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?


  Réponse avec citation
Vieux 26/03/2008, 05h03   #3
Mario Adolf
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Header Question


Martin wrote:
> 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?
>

I've also learnt the hard way that even just a blank line preceeding your
code stuffs it up.
header can be real bitchy.

HTH

Mario


  Réponse avec citation
Vieux 26/03/2008, 05h41   #4
mtek@mtekusa.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Header Question

On Mar 25, 11:03pm, "Mario Adolf" <mo...@ultrafx.de> wrote:
> Martin wrote:
> > 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?

>
> I've also learnt the hard way that even just a blank line preceeding your
> code stuffs it up.
> header can be real bitchy.
>
> HTH
>
> Mario



Found it!!!

I have an include file, which is a very small php script which
initializes some variables. Basically it looks like this:

<?
init variables
?>

It outputs nothing!! Why is this a problem???

So, I guess I need to figure out how to include this file
properly......any suggestions??

John

  Réponse avec citation
Vieux 26/03/2008, 05h50   #5
mtek@mtekusa.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Header Question

On Mar 25, 11:03pm, "Mario Adolf" <mo...@ultrafx.de> wrote:
> Martin wrote:
> > 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?

>
> I've also learnt the hard way that even just a blank line preceeding your
> code stuffs it up.
> header can be real bitchy.
>
> HTH
>
> Mario


Found it!!!

I have an include file, which is a very small php script which
initializes some variables. Basically it looks like this:


<?
init variables
?>


It outputs nothing!! Why is this a problem???


So, I guess I need to figure out how to include this file
properly......any suggestions??

Also, on another note: I know that if my PHP script contains a FORM,
I can pass variables between scripts. But, if I just change the
header location, how can I pass the variable to the php script I am
calling???

Thanks!


John

  Réponse avec citation
Vieux 26/03/2008, 07h52   #6
The Natural Philosopher
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Header Question

mtek@mtekusa.com wrote:
> On Mar 25, 11:03 pm, "Mario Adolf" <mo...@ultrafx.de> wrote:
>> Martin wrote:
>>> 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?

>> I've also learnt the hard way that even just a blank line preceeding your
>> code stuffs it up.
>> header can be real bitchy.
>>
>> HTH
>>
>> Mario

>
>
> Found it!!!
>
> I have an include file, which is a very small php script which
> initializes some variables. Basically it looks like this:
>
> <?
> init variables
> ?>
>
> It outputs nothing!! Why is this a problem???


Probably because there is a space or line after the closing ?>
>
> So, I guess I need to figure out how to include this file
> properly......any suggestions??


Make sure the ?> is absolutely the last thing in the file and <? is
absolutely the first. Anything outrsode the brackets is echoed to he output

>
> John
>

  Réponse avec citation
Vieux 26/03/2008, 07h53   #7
The Natural Philosopher
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Header Question

mtek@mtekusa.com wrote:
>
> Also, on another note: I know that if my PHP script contains a FORM,
> I can pass variables between scripts. But, if I just change the
> header location, how can I pass the variable to the php script I am
> calling???
>

I THINK that will 'just happen'..

Its a browser issue, not a PHP issue..

> Thanks!
>
>
> John
>

  Réponse avec citation
Vieux 26/03/2008, 12h54   #8
Satya
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Header Question

On Mar 26, 5:06pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> m...@mtekusa.com wrote:
> > On Mar 25, 11:03 pm, "Mario Adolf" <mo...@ultrafx.de> wrote:
> >> Martin wrote:
> >>> 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?
> >> I've also learnt the hard way that even just a blank line preceeding your
> >> code stuffs it up.
> >> header can be real bitchy.

>
> >> HTH

>
> >> Mario

>
> > Found it!!!

>
> > I have an include file, which is a very small php script which
> > initializes some variables. Basically it looks like this:

>
> > <?
> > init variables
> > ?>

>
> > It outputs nothing!! Why is this a problem???

>
> > So, I guess I need to figure out how to include this file
> > properly......any suggestions??

>
> 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.
>
> Also, you should always have the following in your php.ini file on your
> development system:
>
> error_reporting=E_ALL (or E_ALL | E_STRICT)
> display_errors=on
>
> This would have displayed an error message when the header() call failed
> and identifying where the output was initiated.
>
> > Also, on another note: I know that if my PHP script contains a FORM,
> > I can pass variables between scripts. But, if I just change the
> > header location, how can I pass the variable to the php script I am
> > calling???

>
> You can pass them as GET values or in the $_SESSION array. Personally,
> I prefer the latter.
>
> > Thanks!

>
> > John

>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================- Hide quoted text -
>
> - Show quoted text -


and, use ob_start(); at the top. Then any output by mistake will not
be out-putted.

http://satya61229.blogspot.com/2007/...fy-header.html
  Réponse avec citation
Vieux 26/03/2008, 13h06   #9
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Header Question

mtek@mtekusa.com wrote:
> On Mar 25, 11:03 pm, "Mario Adolf" <mo...@ultrafx.de> wrote:
>> Martin wrote:
>>> 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?

>> I've also learnt the hard way that even just a blank line preceeding your
>> code stuffs it up.
>> header can be real bitchy.
>>
>> HTH
>>
>> Mario

>
> Found it!!!
>
> I have an include file, which is a very small php script which
> initializes some variables. Basically it looks like this:
>
>
> <?
> init variables
> ?>
>
>
> It outputs nothing!! Why is this a problem???
>
>
> So, I guess I need to figure out how to include this file
> properly......any suggestions??
>


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.

Also, you should always have the following in your php.ini file on your
development system:

error_reporting=E_ALL (or E_ALL | E_STRICT)
display_errors=on

This would have displayed an error message when the header() call failed
and identifying where the output was initiated.

> Also, on another note: I know that if my PHP script contains a FORM,
> I can pass variables between scripts. But, if I just change the
> header location, how can I pass the variable to the php script I am
> calling???
>


You can pass them as GET values or in the $_SESSION array. Personally,
I prefer the latter.

> Thanks!
>
>
> John
>
>



--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  Réponse avec citation
Vieux 26/03/2008, 13h09   #10
mtek@mtekusa.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Header Question

On Mar 26, 7:06 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> m...@mtekusa.com wrote:
> > On Mar 25, 11:03 pm, "Mario Adolf" <mo...@ultrafx.de> wrote:
> >> Martin wrote:
> >>> 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?
> >> I've also learnt the hard way that even just a blank line preceeding your
> >> code stuffs it up.
> >> header can be real bitchy.

>
> >> HTH

>
> >> Mario

>
> > Found it!!!

>
> > I have an include file, which is a very small php script which
> > initializes some variables. Basically it looks like this:

>
> > <?
> > init variables
> > ?>

>
> > It outputs nothing!! Why is this a problem???

>
> > So, I guess I need to figure out how to include this file
> > properly......any suggestions??

>
> 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.
>
> Also, you should always have the following in your php.ini file on your
> development system:
>
> error_reporting=E_ALL (or E_ALL | E_STRICT)
> display_errors=on
>
> This would have displayed an error message when the header() call failed
> and identifying where the output was initiated.
>
> > Also, on another note: I know that if my PHP script contains a FORM,
> > I can pass variables between scripts. But, if I just change the
> > header location, how can I pass the variable to the php script I am
> > calling???

>
> You can pass them as GET values or in the $_SESSION array. Personally,
> I prefer the latter.
>
> > Thanks!

>
> > John

>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================



I'll have to look up $_SESSION, I've never seen or used that
before.......

  Réponse avec citation
Vieux 26/03/2008, 14h12   #11
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Header Question

Satya wrote:
> On Mar 26, 5:06 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>> m...@mtekusa.com wrote:
>>> On Mar 25, 11:03 pm, "Mario Adolf" <mo...@ultrafx.de> wrote:
>>>> Martin wrote:
>>>>> 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?
>>>> I've also learnt the hard way that even just a blank line preceeding your
>>>> code stuffs it up.
>>>> header can be real bitchy.
>>>> HTH
>>>> Mario
>>> Found it!!!
>>> I have an include file, which is a very small php script which
>>> initializes some variables. Basically it looks like this:
>>> <?
>>> init variables
>>> ?>
>>> It outputs nothing!! Why is this a problem???
>>> So, I guess I need to figure out how to include this file
>>> properly......any suggestions??

>> 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.
>>
>> Also, you should always have the following in your php.ini file on your
>> development system:
>>
>> error_reporting=E_ALL (or E_ALL | E_STRICT)
>> display_errors=on
>>
>> This would have displayed an error message when the header() call failed
>> and identifying where the output was initiated.
>>
>>> Also, on another note: I know that if my PHP script contains a FORM,
>>> I can pass variables between scripts. But, if I just change the
>>> header location, how can I pass the variable to the php script I am
>>> calling???

>> You can pass them as GET values or in the $_SESSION array. Personally,
>> I prefer the latter.
>>
>>> Thanks!
>>> John

>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================- Hide quoted text -
>>
>> - Show quoted text -

>
> and, use ob_start(); at the top. Then any output by mistake will not
> be out-putted.
>
> http://satya61229.blogspot.com/2007/...fy-header.html
>


WRONG, WRONG, WRONG! All that does is hide the error, not fix it.

The problem still exists, and ob_start() causes other problems - like
delaying output to the browser, which means higher server loads and
poorer performance to the client.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  Réponse avec citation
Vieux 26/03/2008, 16h01   #12
mtek@mtekusa.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Header Question

On Mar 26, 8:12 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> Satya wrote:
> > On Mar 26, 5:06 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> >> m...@mtekusa.com wrote:
> >>> On Mar 25, 11:03 pm, "Mario Adolf" <mo...@ultrafx.de> wrote:
> >>>> Martin wrote:
> >>>>> 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?
> >>>> I've also learnt the hard way that even just a blank line preceeding your
> >>>> code stuffs it up.
> >>>> header can be real bitchy.
> >>>> HTH
> >>>> Mario
> >>> Found it!!!
> >>> I have an include file, which is a very small php script which
> >>> initializes some variables. Basically it looks like this:
> >>> <?
> >>> init variables
> >>> ?>
> >>> It outputs nothing!! Why is this a problem???
> >>> So, I guess I need to figure out how to include this file
> >>> properly......any suggestions??
> >> 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.

>
> >> Also, you should always have the following in your php.ini file on your
> >> development system:

>
> >> error_reporting=E_ALL (or E_ALL | E_STRICT)
> >> display_errors=on

>
> >> This would have displayed an error message when the header() call failed
> >> and identifying where the output was initiated.

>
> >>> Also, on another note: I know that if my PHP script contains a FORM,
> >>> I can pass variables between scripts. But, if I just change the
> >>> header location, how can I pass the variable to the php script I am
> >>> calling???
> >> You can pass them as GET values or in the $_SESSION array. Personally,
> >> I prefer the latter.

>
> >>> Thanks!
> >>> John
> >> --
> >> ==================
> >> Remove the "x" from my email address
> >> Jerry Stuckle
> >> JDS Computer Training Corp.
> >> jstuck...@attglobal.net
> >> ==================- Hide quoted text -

>
> >> - Show quoted text -

>
> > and, use ob_start(); at the top. Then any output by mistake will not
> > be out-putted.

>
> >http://satya61229.blogspot.com/2007/...fy-header.html

>
> WRONG, WRONG, WRONG! All that does is hide the error, not fix it.
>
> The problem still exists, and ob_start() causes other problems - like
> delaying output to the browser, which means higher server loads and
> poorer performance to the client.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================



What do you suggest to solve the issues?
  Réponse avec citation
Vieux 26/03/2008, 16h41   #13
Guillaume
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Header Question

mtek@mtekusa.com a écrit :
>>>> 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.

[...]
> 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
  Réponse avec citation
Vieux 26/03/2008, 18h13   #14
mtek@mtekusa.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Header Question

On Mar 26, 1:04 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> m...@mtekusa.com wrote:
> > On Mar 26, 8:12 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> >> Satya wrote:
> >>> On Mar 26, 5:06 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> >>>> m...@mtekusa.com wrote:
> >>>>> On Mar 25, 11:03 pm, "Mario Adolf" <mo...@ultrafx.de> wrote:
> >>>>>> Martin wrote:
> >>>>>>> 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?
> >>>>>> I've also learnt the hard way that even just a blank line preceeding your
> >>>>>> code stuffs it up.
> >>>>>> header can be real bitchy.
> >>>>>> HTH
> >>>>>> Mario
> >>>>> Found it!!!
> >>>>> I have an include file, which is a very small php script which
> >>>>> initializes some variables. Basically it looks like this:
> >>>>> <?
> >>>>> init variables
> >>>>> ?>
> >>>>> It outputs nothing!! Why is this a problem???
> >>>>> So, I guess I need to figure out how to include this file
> >>>>> properly......any suggestions??
> >>>> 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.
> >>>> Also, you should always have the following in your php.ini file on your
> >>>> development system:
> >>>> error_reporting=E_ALL (or E_ALL | E_STRICT)
> >>>> display_errors=on
> >>>> This would have displayed an error message when the header() call failed
> >>>> and identifying where the output was initiated.
> >>>>> Also, on another note: I know that if my PHP script contains a FORM,
> >>>>> I can pass variables between scripts. But, if I just change the
> >>>>> header location, how can I pass the variable to the php script I am
> >>>>> calling???
> >>>> You can pass them as GET values or in the $_SESSION array. Personally,
> >>>> I prefer the latter.
> >>>>> Thanks!
> >>>>> John
> >>>> --
> >>>> ==================
> >>>> Remove the "x" from my email address
> >>>> Jerry Stuckle
> >>>> JDS Computer Training Corp.
> >>>> jstuck...@attglobal.net
> >>>> ==================- Hide quoted text -
> >>>> - Show quoted text -
> >>> and, use ob_start(); at the top. Then any output by mistake will not
> >>> be out-putted.
> >>>http://satya61229.blogspot.com/2007/...fy-header.html
> >> WRONG, WRONG, WRONG! All that does is hide the error, not fix it.

>
> >> The problem still exists, and ob_start() causes other problems - like
> >> delaying output to the browser, which means higher server loads and
> >> poorer performance to the client.

>
> >> --
> >> ==================
> >> Remove the "x" from my email address
> >> Jerry Stuckle
> >> JDS Computer Training Corp.
> >> jstuck...@attglobal.net
> >> ==================

>
> > What do you suggest to solve the issues?

>
> Fix the problem.
>
> Somewhere you are outputting something - as others have indicated, you
> probably have something outside the <?php ... ?> in your included file.
>
> Even white space will do it.
>
> Turn on your errors and display them. That will show you where the
> output was initiated. On a development system, your php.ini file should
> always have:
>
> error_reporting=E_ALL
> display_errors=on
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================



Hi,

Thanks for all your suggestions. I was able to solve the issue with
the blank page. However, I'm still not passing any variables.

Basically the customer chooses a date in which to edit data. When he
does that, he is brought to another page where he can select the data
he wants to edit for that date. All those variables get passed
properly. Next, he selects the data to edit and is brought to an edit
screen. All that seems to work and the variables are passed. But,
when done editing and he returns to the previous page, no variables
are passed back.

The only difference is that when he saves the data, it calls a PHP
script to save the data, and then changes the header to return to the
previous page. Maybe I am not doing this correctly? I mean, from the
save script, it is just changing the location. It is not using a form
or anything.....

Thanks!

John.

  Réponse avec citation
Vieux 26/03/2008, 19h04   #15
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Header Question

mtek@mtekusa.com wrote:
> On Mar 26, 8:12 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>> Satya wrote:
>>> On Mar 26, 5:06 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>>>> m...@mtekusa.com wrote:
>>>>> On Mar 25, 11:03 pm, "Mario Adolf" <mo...@ultrafx.de> wrote:
>>>>>> Martin wrote:
>>>>>>> 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?
>>>>>> I've also learnt the hard way that even just a blank line preceeding your
>>>>>> code stuffs it up.
>>>>>> header can be real bitchy.
>>>>>> HTH
>>>>>> Mario
>>>>> Found it!!!
>>>>> I have an include file, which is a very small php script which
>>>>> initializes some variables. Basically it looks like this:
>>>>> <?
>>>>> init variables
>>>>> ?>
>>>>> It outputs nothing!! Why is this a problem???
>>>>> So, I guess I need to figure out how to include this file
>>>>> properly......any suggestions??
>>>> 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.
>>>> Also, you should always have the following in your php.ini file on your
>>>> development system:
>>>> error_reporting=E_ALL (or E_ALL | E_STRICT)
>>>> display_errors=on
>>>> This would have displayed an error message when the header() call failed
>>>> and identifying where the output was initiated.
>>>>> Also, on another note: I know that if my PHP script contains a FORM,
>>>>> I can pass variables between scripts. But, if I just change the
>>>>> header location, how can I pass the variable to the php script I am
>>>>> calling???
>>>> You can pass them as GET values or in the $_SESSION array. Personally,
>>>> I prefer the latter.
>>>>> Thanks!
>>>>> John
>>>> --
>>>> ==================
>>>> Remove the "x" from my email address
>>>> Jerry Stuckle
>>>> JDS Computer Training Corp.
>>>> jstuck...@attglobal.net
>>>> ==================- Hide quoted text -
>>>> - Show quoted text -
>>> and, use ob_start(); at the top. Then any output by mistake will not
>>> be out-putted.
>>> http://satya61229.blogspot.com/2007/...fy-header.html

>> WRONG, WRONG, WRONG! All that does is hide the error, not fix it.
>>
>> The problem still exists, and ob_start() causes other problems - like
>> delaying output to the browser, which means higher server loads and
>> poorer performance to the client.
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================

>
>
> What do you suggest to solve the issues?
>


Fix the problem.

Somewhere you are outputting something - as others have indicated, you
probably have something outside the <?php ... ?> in your included file.

Even white space will do it.

Turn on your errors and display them. That will show you where the
output was initiated. On a development system, your php.ini file should
always have:

error_reporting=E_ALL
display_errors=on


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  Réponse avec citation
Vieux 26/03/2008, 20h05   #16
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Header Question

mtek@mtekusa.com wrote:
> On Mar 26, 1:04 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>> m...@mtekusa.com wrote:
>>> On Mar 26, 8:12 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>>>> Satya wrote:
>>>>> On Mar 26, 5:06 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>>>>>> m...@mtekusa.com wrote:
>>>>>>> On Mar 25, 11:03 pm, "Mario Adolf" <mo...@ultrafx.de> wrote:
>>>>>>>> Martin wrote:
>>>>>>>>> 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?
>>>>>>>> I've also learnt the hard way that even just a blank line preceeding your
>>>>>>>> code stuffs it up.
>>>>>>>> header can be real bitchy.
>>>>>>>> HTH
>>>>>>>> Mario
>>>>>>> Found it!!!
>>>>>>> I have an include file, which is a very small php script which
>>>>>>> initializes some variables. Basically it looks like this:
>>>>>>> <?
>>>>>>> init variables
>>>>>>> ?>
>>>>>>> It outputs nothing!! Why is this a problem???
>>>>>>> So, I guess I need to figure out how to include this file
>>>>>>> properly......any suggestions??
>>>>>> 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.
>>>>>> Also, you should always have the following in your php.ini file on your
>>>>>> development system:
>>>>>> error_reporting=E_ALL (or E_ALL | E_STRICT)
>>>>>> display_errors=on
>>>>>> This would have displayed an error message when the header() call failed
>>>>>> and identifying where the output was initiated.
>>>>>>> Also, on another note: I know that if my PHP script contains a FORM,
>>>>>>> I can pass variables between scripts. But, if I just change the
>>>>>>> header location, how can I pass the variable to the php script I am
>>>>>>> calling???
>>>>>> You can pass them as GET values or in the $_SESSION array. Personally,
>>>>>> I prefer the latter.
>>>>>>> Thanks!
>>>>>>> John
>>>>>> --
>>>>>> ==================
>>>>>> Remove the "x" from my email address
>>>>>> Jerry Stuckle
>>>>>> JDS Computer Training Corp.
>>>>>> jstuck...@attglobal.net
>>>>>> ==================- Hide quoted text -
>>>>>> - Show quoted text -
>>>>> and, use ob_start(); at the top. Then any output by mistake will not
>>>>> be out-putted.
>>>>> http://satya61229.blogspot.com/2007/...fy-header.html
>>>> WRONG, WRONG, WRONG! All that does is hide the error, not fix it.
>>>> The problem still exists, and ob_start() causes other problems - like
>>>> delaying output to the browser, which means higher server loads and
>>>> poorer performance to the client.
>>>> --
>>>> ==================
>>>> Remove the "x" from my email address
>>>> Jerry Stuckle
>>>> JDS Computer Training Corp.
>>>> jstuck...@attglobal.net
>>>> ==================
>>> What do you suggest to solve the issues?

>> Fix the problem.
>>
>> Somewhere you are outputting something - as others have indicated, you
>> probably have something outside the <?php ... ?> in your included file.
>>
>> Even white space will do it.
>>
>> Turn on your errors and display them. That will show you where the
>> output was initiated. On a development system, your php.ini file should
>> always have:
>>
>> error_reporting=E_ALL
>> display_errors=on
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================

>
>
> Hi,
>
> Thanks for all your suggestions. I was able to solve the issue with
> the blank page. However, I'm still not passing any variables.
>
> Basically the customer chooses a date in which to edit data. When he
> does that, he is brought to another page where he can select the data
> he wants to edit for that date. All those variables get passed
> properly. Next, he selects the data to edit and is brought to an edit
> screen. All that seems to work and the variables are passed. But,
> when done editing and he returns to the previous page, no variables
> are passed back.
>
> The only difference is that when he saves the data, it calls a PHP
> script to save the data, and then changes the header to return to the
> previous page. Maybe I am not doing this correctly? I mean, from the
> save script, it is just changing the location. It is not using a form
> or anything.....
>
> Thanks!
>
> John.
>
>


A header call is just a command to the browser to GET the new page. Any
posted values are not passed.

The easiest way to pass values is in the $_SESSION array, i.e.

session_start();
$_SESSION['p1'] = $val1;
$_SESSION['p2'] = $val2;
// etc.

Then to fetch them in the new page, use:

session_start();
$val1 = $_SESSION['p1'];
$val2 = $_SESSION['p2'];
// etc.

session_start() must be called before any output is sent, just like
header() must.

A poorer alternative would be to add the parameters to your URL and
fetch them as GET parameters, i.e.

header("Location:http://www.example.com/mypage.php?p1=$val1&p2=$val2");

Then fetch the values with

$val1 = $_GET['p1'];
$val2 = $_GET['p2'];
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 05h24.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,39005 seconds with 24 queries