I"m a newbie and running php on Linux

I"m a newbie and running php on Linux

am 31.03.2010 18:32:34 von King Coffee

Hi,

I ran the following code snippet on Windows IIS 7, in my index.php file and
it worked fine. But when run it on Linux, the "die" code is executed.

Is there an include file or something else I need to to process this on a
linux server?

echo '

Redirecting... Please Wait

';
/*
redirect('welcome.html');
*/
if (!headers_sent()) {
header('Location: ' . 'http://auction.househops.com/index.php');
} else {
die('Could not redirect.');
}
?>


Thanks,
King


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: I"m a newbie and running php on Linux

am 31.03.2010 18:36:08 von Ashley Sheridan

--=-kGpj4aWYyPoPx8i+9Ts+
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Wed, 2010-03-31 at 11:32 -0500, King Coffee wrote:

> Hi,
>
> I ran the following code snippet on Windows IIS 7, in my index.php file and
> it worked fine. But when run it on Linux, the "die" code is executed.
>
> Is there an include file or something else I need to to process this on a
> linux server?
>
> > echo '

Redirecting... Please Wait

';
> /*
> redirect('welcome.html');
> */
> if (!headers_sent()) {
> header('Location: ' . 'http://auction.househops.com/index.php');
> } else {
> die('Could not redirect.');
> }
> ?>
>
>
> Thanks,
> King
>
>


This should never ever redirect. You've got an echo statement as your
first line of code. Once output has been sent to the browser, PHP cannot
send a redirect header, as the default ones get sent with the output.

I think maybe you'd need a Javascript redirect here, but that comes with
a warning that you cannot rely on everyone to have Javascript available
or enabled on their browser. People do turn it off, people do use
plugins such as NoScript, some routers have been known to strip
Javascript from web pages and not ever browser supports all Javascript
(think text browsers, speech and Braille browsers, etc)

Why do you need to echo out a message to the user that the browser is
redirecting anyway? A header redirect will be seamless and the user
shouldn't even notice anything happening except for the URL changing.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-kGpj4aWYyPoPx8i+9Ts+--

Re: I"m a newbie and running php on Linux

am 31.03.2010 18:41:09 von jose javier parra sanchez

Check your php.ini , look for output_buffering

2010/3/31 King Coffee :
> Hi,
>
> I ran the following code snippet on Windows IIS 7, in my index.php file a=
nd
> it worked fine. But when run it on Linux, the "die" code is executed.
>
> Is there an include file or something else I need to to process this on a
> linux server?
>
> > =A0 =A0 =A0 =A0echo '

Redirecting... Please Wait

';
> /*
> =A0 =A0 =A0 =A0redirect('welcome.html');
> */
> =A0 =A0 =A0 =A0if (!headers_sent()) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0header('Location: ' .
> 'http://auction.househops.com/index.php');
> =A0 =A0 =A0 =A0} else {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0die('Could not redirect.');
> =A0 =A0 =A0 =A0}
> ?>
>
>
> Thanks,
> King
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: I"m a newbie and running php on Linux

am 31.03.2010 18:55:26 von Nathan Rixham

Ashley Sheridan wrote:
> On Wed, 2010-03-31 at 11:32 -0500, King Coffee wrote:
>
>> Hi,
>>
>> I ran the following code snippet on Windows IIS 7, in my index.php file and
>> it worked fine. But when run it on Linux, the "die" code is executed.
>>
>> Is there an include file or something else I need to to process this on a
>> linux server?
>>
>> >> echo '

Redirecting... Please Wait

';
>> /*
>> redirect('welcome.html');
>> */
>> if (!headers_sent()) {
>> header('Location: ' . 'http://auction.househops.com/index.php');
>> } else {
>> die('Could not redirect.');
>> }
>> ?>
>>
>>
>> Thanks,
>> King
>>
>>
>
>
> This should never ever redirect. You've got an echo statement as your
> first line of code. Once output has been sent to the browser, PHP cannot
> send a redirect header, as the default ones get sent with the output.

problem is very very simple; simply swap the code order

// add in logic if you want
header('Location: ' . 'http://auction.househops.com/index.php');
echo '

Redirecting... Please Wait

';
?>

but please expand including a link to where you are redirecting too.

The apache default pages are very very good and include the status
(+code) and a short note:
302 Found
The resource you requested has been found

note: that's not the exact text, but you get the idea.

> I think maybe you'd need a Javascript redirect here, but that comes with
> a warning that you cannot rely on everyone to have Javascript available
> or enabled on their browser. People do turn it off, people do use
> plugins such as NoScript, some routers have been known to strip
> Javascript from web pages and not ever browser supports all Javascript
> (think text browsers, speech and Braille browsers, etc)

no no no; (sorry ash) but HTTP is there for a reason and it accommodates
everything we need + can be used for *any* file (how do you javascript
redirect an image for instance) - all catered for.

always remember that the web is built on http & hypermedia (media w/
links); it's the whole reason we have a web, is the web and works v well.

also worth noting that apache foundation formed by roy t fielding, same
man who wrote rest, which is the model for http, and check the name at
the top of http, roy again; he's put in tonnes of work and guidance to
the full net, and of course apache http server itself - when in doublt
just copy apache and read the rfc + dissertation.

> Why do you need to echo out a message to the user that the browser is
> redirecting anyway? A header redirect will be seamless and the user
> shouldn't even notice anything happening except for the URL changing.

because user agents MAY redirect, they don't have to - and when its a
post or such like they may want to make the choice of whether to proceed
or not; likewise from https to http and so forth.

http rfc is pretty clear that with every 3xx & 4xx status could you
should give a reason as to why and also give possible actions the user
an take next - preferably as hypermedia links to make it properly resftul.

"307 Temporary redirect, redirecting you to click the link if you
are not automatically redirected".

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: I"m a newbie and running php on Linux

am 31.03.2010 20:25:10 von King Coffee

Thanks,
I think Output_Buffering may be the difference on the two servers. I had a
default php.ini on the Linux server but not on the Windows server. But for
now, I remove the echo statement.

Thank,
King

"jose javier parra sanchez" wrote in message
news:r2j99f1636c1003310941xdc809603l774b40457870b7c7@mail.gm ail.com...
> Check your php.ini , look for output_buffering
>
> 2010/3/31 King Coffee :
>> Hi,
>>
>> I ran the following code snippet on Windows IIS 7, in my index.php file
>> and
>> it worked fine. But when run it on Linux, the "die" code is executed.
>>
>> Is there an include file or something else I need to to process this on a
>> linux server?
>>
>> >> echo '

Redirecting... Please Wait

';
>> /*
>> redirect('welcome.html');
>> */
>> if (!headers_sent()) {
>> header('Location: ' .
>> 'http://auction.househops.com/index.php');
>> } else {
>> die('Could not redirect.');
>> }
>> ?>
>>
>>
>> Thanks,
>> King
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: I"m a newbie and running php on Linux

am 31.03.2010 20:27:01 von King Coffee

Thanks you Nathan.
That worked.
Sincerely,
King

"Nathan Rixham" wrote in message
news:4BB37E7E.5040402@gmail.com...
> Ashley Sheridan wrote:
>> On Wed, 2010-03-31 at 11:32 -0500, King Coffee wrote:
>>
>>> Hi,
>>>
>>> I ran the following code snippet on Windows IIS 7, in my index.php file
>>> and
>>> it worked fine. But when run it on Linux, the "die" code is executed.
>>>
>>> Is there an include file or something else I need to to process this on
>>> a
>>> linux server?
>>>
>>> >>> echo '

Redirecting... Please Wait

';
>>> /*
>>> redirect('welcome.html');
>>> */
>>> if (!headers_sent()) {
>>> header('Location: ' . 'http://auction.househops.com/index.php');
>>> } else {
>>> die('Could not redirect.');
>>> }
>>> ?>
>>>
>>>
>>> Thanks,
>>> King
>>>
>>>
>>
>>
>> This should never ever redirect. You've got an echo statement as your
>> first line of code. Once output has been sent to the browser, PHP cannot
>> send a redirect header, as the default ones get sent with the output.
>
> problem is very very simple; simply swap the code order
>
> > // add in logic if you want
> header('Location: ' . 'http://auction.househops.com/index.php');
> echo '

Redirecting... Please Wait

';
> ?>
>
> but please expand including a link to where you are redirecting too.
>
> The apache default pages are very very good and include the status
> (+code) and a short note:
> 302 Found
> The resource you requested has been found
>
> note: that's not the exact text, but you get the idea.
>
>> I think maybe you'd need a Javascript redirect here, but that comes with
>> a warning that you cannot rely on everyone to have Javascript available
>> or enabled on their browser. People do turn it off, people do use
>> plugins such as NoScript, some routers have been known to strip
>> Javascript from web pages and not ever browser supports all Javascript
>> (think text browsers, speech and Braille browsers, etc)
>
> no no no; (sorry ash) but HTTP is there for a reason and it accommodates
> everything we need + can be used for *any* file (how do you javascript
> redirect an image for instance) - all catered for.
>
> always remember that the web is built on http & hypermedia (media w/
> links); it's the whole reason we have a web, is the web and works v well.
>
> also worth noting that apache foundation formed by roy t fielding, same
> man who wrote rest, which is the model for http, and check the name at
> the top of http, roy again; he's put in tonnes of work and guidance to
> the full net, and of course apache http server itself - when in doublt
> just copy apache and read the rfc + dissertation.
>
>> Why do you need to echo out a message to the user that the browser is
>> redirecting anyway? A header redirect will be seamless and the user
>> shouldn't even notice anything happening except for the URL changing.
>
> because user agents MAY redirect, they don't have to - and when its a
> post or such like they may want to make the choice of whether to proceed
> or not; likewise from https to http and so forth.
>
> http rfc is pretty clear that with every 3xx & 4xx status could you
> should give a reason as to why and also give possible actions the user
> an take next - preferably as hypermedia links to make it properly resftul.
>
> "307 Temporary redirect, redirecting you to click the link if you
> are not automatically redirected".


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: I"m a newbie and running php on Linux

am 31.03.2010 20:32:59 von Tommy Pham

On Wed, Mar 31, 2010 at 11:25 AM, King Coffee wrote:
> Thanks,
> I think Output_Buffering may be the difference on the two servers. I had =
a
> default php.ini on the Linux server but not on the Windows server. But fo=
r
> now, I remove the echo statement.
>
> Thank,
> King
>
> "jose javier parra sanchez" wrote in message
> news:r2j99f1636c1003310941xdc809603l774b40457870b7c7@mail.gm ail.com...
>>
>> Check your php.ini , look for output_buffering
>>
>> 2010/3/31 King Coffee :
>>>
>>> Hi,
>>>
>>> I ran the following code snippet on Windows IIS 7, in my index.php file
>>> and
>>> it worked fine. But when run it on Linux, the "die" code is executed.
>>>
>>> Is there an include file or something else I need to to process this on=
a
>>> linux server?
>>>
>>> >>>       echo '

Redirecting... Please Wait

';
>>> /*
>>>       redirect('welcome.html');
>>> */
>>>       if (!headers_sent()) {
>>>               header('Location: ' .
>>> 'http://auction.househops.com/index.php');
>>>       } else {
>>>               die('Could not redirec=
t.');
>>>       }
>>> ?>
>>>
>>>
>>> Thanks,
>>> King
>>>

Having that echo in there pointless since PHP will redirect
immediately. If you want to inform the users that they're being
redirected because of URL changes, then look into meta tag for the
delayed redirect and you still have that echo for informative
purposes. You may also need to set the set headers with proper http
code for the search engines.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php