Swithching to a new file

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
Dmitrit Plakhotnik
New php-forum User
New php-forum User
Posts: 13
Joined: Fri Nov 01, 2002 6:56 am

Fri Dec 06, 2002 3:27 am

if you want use for redirect header("Location:"), make sure what before nothing outputing on the page.

for example
wrong code

Code: Select all

 <? echo "test"; 
header("Location: index.php"); ?>

right code

Code: Select all

 <? header("Location: index.php"); ?>

but of you must redirect after printing use jabascript

Code: Select all

function pggo($prfx,$me="document.location"){
  echo "
    <script language=javascript>
  if($me=="document.location") echo "nm=new String($me);";else echo "nm=new String('$me');";
   echo "   if(nm.length<100)document.location=nm+'$prfx';
Dmitriy S. Plakhotnik
AlarIT programmer

New php-forum User
New php-forum User
Posts: 7
Joined: Sun Dec 08, 2002 9:02 pm

Sun Dec 08, 2002 9:49 pm

sam wrote:Thanks for that:

Yesturday I spent about three hours working out that I had white spaces after my ?> closing tags on files that I was including before redirecting :twisted:

Panfull stuff, we get ourselves into with those invisible white spaces :wink: .

Another question though, my server does not explicitely tell me that output was passed before the header location was executed. How do I change this. Is it an apache setting or php setting ?

Thanks again though

try to configure you register_globals it might be off in you php.ini

Post Reply