[PHP] redirect without using header

2002-11-13 Thread pig pig
Hi there,

Is there a way to do redirect to another page without
using the header function.

I am getting an error by using header but I couldn't
find any part of my code that output anything before
using header.

Thanks in advance
CK Ong

__
Do You Yahoo!?
Great flight deals, travel info and prizes!
http://sg.travel.yahoo.com

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




Re: [PHP] redirect without using header

2002-11-13 Thread Heilig (Cece) Szabolcs
Hello!

 I am getting an error by using header but I couldn't
 find any part of my code that output anything before
 using header.

Check your included files what included before using header();
These files start with ? and ends with ? without whitespace after that?

And you can use ob_start() at the start and ob_end_flush() at the end,
and no problems with outputting before add headers.

=
Heilig (Cece) Szabolcs - [EMAIL PROTECTED] - http://www.phphost.hu
= 

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




Re: [PHP] redirect without using header

2002-11-13 Thread 1LT John W. Holmes
 Hi there,

 Is there a way to do redirect to another page without
 using the header function.

 I am getting an error by using header but I couldn't
 find any part of my code that output anything before
 using header.

The error message tells you where output was started. It says something like
output started in /path/to/file.php:XXX where XXX is the line number of
that file that created output.

If you show some of your code, it'll help.

Otherwise, workarounds include output buffering and javascript.

---John Holmes...


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




Re: [PHP] redirect without using header

2002-11-13 Thread pig pig
Hi Heilig,

I have been trying to use the ob_start and
ob_end_flush(), but I am not sure where to put them.

I try putting just before the header() but it still
produce the warning that something has been output to
the browser.

Thanks
CK Ong
 --- Heilig (Cece) Szabolcs [EMAIL PROTECTED] wrote:
 Hello!
 
  I am getting an error by using header but I
 couldn't
  find any part of my code that output anything
 before
  using header.
 
 Check your included files what included before using
 header();
 These files start with ? and ends with ? without
 whitespace after that?
 
 And you can use ob_start() at the start and
 ob_end_flush() at the end,
 and no problems with outputting before add headers.
 

=
 Heilig (Cece) Szabolcs - [EMAIL PROTECTED] -
 http://www.phphost.hu

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

__
Do You Yahoo!?
Great flight deals, travel info and prizes!
http://sg.travel.yahoo.com

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




Re: [PHP] redirect without using header

2002-11-13 Thread Heilig (Cece) Szabolcs
Start your code with ob_start()
It fires up an output buffer, does not output (and headers)
until ob_end_flush() called.
Put ob_end_flush() after all, before last ?

Your code might looks as follows:

?php

ob_start();
echo whatever;
header whatever;
ob_end_flush();

?

=
Heilig (Cece) Szabolcs - [EMAIL PROTECTED] - http://www.phphost.hu
=

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




Re: [PHP] redirect without using header

2002-11-13 Thread @ Edwin
Hello,

pig pig [EMAIL PROTECTED] wrote:

 function Order_action($sAction)
 {
   global $db;
   global $sForm;
   global $sOrderErr;

   $sParams = ;
   $sActionFileName = ShoppingCart.php?;

  do some error checking


...[snip]...

I'm not sure but this could be because of some errors being reported. (Thus,
headers already sent message...) Try turning off error reporting in your
php.ini (temporarily), restart your web server, and try the script again.

If it works, put everything back (in php.ini, I mean) and get rid of any
bug that is causing the error...

- E


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




RE: [PHP] redirect without using header

2002-11-13 Thread pig pig
The problem I am expriencing now is intermittent. 
Sometime the CGI error will appear and sometime it
works fine.  Could it be the latency in the network
that is causing the problem?  Just before the call to
header() there is a db query.

Any suggestion would be appreciated.

I have been trying for a few days and still getting
nowhere.

Thanks
CK Ong
 --- Cal Evans [EMAIL PROTECTED] wrote:  .
 .
 .
   ob_end_clean();
   header(Location:  . $sActionFileName);
   die();
 
 I always put a die() after my redirect headers
 unless I WANT it to continue
 processing for some reason.  In the past I've had
 PHP not immediately
 redirect and it cause me problems.
 
 =C=
 *
 * Cal Evans
 * The Virtual CIO
 * http://www.calevans.com
 *
 
 
 -Original Message-
 From: pig pig [mailto:pigpig8080;yahoo.com.sg]
 Sent: Wednesday, November 13, 2002 7:47 AM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP] redirect without using header
 
 
 function Order_action($sAction)
 {
   global $db;
   global $sForm;
   global $sOrderErr;
 
   $sParams = ;
   $sActionFileName = ShoppingCart.php?;
 
  do some error checking
 
 
   //-- Create SQL statement
   $sSQL = ;
 
   //-- Execute SQL query
   $db-query($sSQL);
 
   ob_end_clean();
   header(Location:  . $sActionFileName);
 }
 
 It give the error below:
 CGI Error
 The specified CGI application misbehaved by not
 returning a complete set of HTTP headers. The
 headers
 it did return are:p/ppre/pre
 
 
 Any help will be appreciated.
 Thanks in advance
 CK Ong
 
  --- pig pig [EMAIL PROTECTED] wrote:  Hi
 Heilig,
 
  I have been trying to use the ob_start and
  ob_end_flush(), but I am not sure where to put
 them.
 
  I try putting just before the header() but it
 still
  produce the warning that something has been output
  to
  the browser.
 
  Thanks
  CK Ong
   --- Heilig (Cece) Szabolcs [EMAIL PROTECTED]
  wrote:
   Hello!
  
I am getting an error by using header but I
   couldn't
find any part of my code that output anything
   before
using header.
  
   Check your included files what included before
  using
   header();
   These files start with ? and ends with ?
 without
   whitespace after that?
  
   And you can use ob_start() at the start and
   ob_end_flush() at the end,
   and no problems with outputting before add
  headers.
  
  
 

=
   Heilig (Cece) Szabolcs - [EMAIL PROTECTED] -
   http://www.phphost.hu
  
 

=
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit:
  http://www.php.net/unsub.php
  
 
  __
  Do You Yahoo!?
  Great flight deals, travel info and prizes!
  http://sg.travel.yahoo.com
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit:
 http://www.php.net/unsub.php
 
 
 __
 Do You Yahoo!?
 Great flight deals, travel info and prizes!
 http://sg.travel.yahoo.com
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
  

__
Do You Yahoo!?
Play for a chance to win a trip to Sydney!
http://sg.mobile.yahoo.com

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




Re: [PHP] redirect without using header

2002-11-13 Thread Chris Shiflett
pig pig wrote:


The problem I am expriencing now is intermittent. 
Sometime the CGI error will appear and sometime it
works fine.  Could it be the latency in the network
that is causing the problem?  Just before the call to
header() there is a db query.


Someone else might have suggested this, but a good way to debug any 
header() related problem is to remove the call to header() and replace 
it with some sort of debugging output. For example, if you had the 
following script ...

?
if ($blah;)
{
$foo=bar;
}
header(Location: http://www.php.net/;);
?

... you will get a parse error because of the statement on line 2. This 
parse error gets output just like an echo statement would, so it creates 
another error when you try to then manipulate the HTTP headers. This 
error is usually the one you will see on the screen. If you don't catch 
the syntax error, you might not see how it is possible that any output 
occurs before the header() call.

If you replace this code with this ...

?
if ($blah;)
{
$foo=bar;
}
echo h3[Location: http://www.php.net/]/h3;
?

... you will see the parse error as well as the value of the header you 
were going to send (which might not be static as illustrated here) on 
the screen. This can reveal some really frustrating bugs sometimes.

Of course, I am assuming your error was something like, headers already 
sent on line ..., so if that isn't the error, this might all be useless 
advice. :-)

Chris


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