problem with redirecting
Maybe sb. will explain me why it doesn't work - everything seems to be ok?

[1.php]<a href="connect.php">go</a>[/1.php]

and in the same dir:

[connect.php]<?php header("Location: 1.php");?>[/connect.php]

I have checked for any logs (Apache 1.3.22)/PHP 4.2.3 on Windows 2000 and there is nothing about any possible errors. But it doesn't work it does not redirect me to 1.php

Why?
Anybody knows?

    i've had the same problem wiht location headers before on apache and unix. Seems like i have to have the header inside someting for it to work.

    like:

    <?php
    
      if($action){
           header("location: wherever.php");
      }
    
    ?>
    

    that usually seems to work for me.

      [1.php]<a href="connect.php">go</a>[/1.php]

      what is this and what does it have to do with header() not redirecting you?

      To redirect someone:

      header("Location: yourfile.php");

      if it's not within your site, then use a full url

      header("Location: [url]http://www.yahoo.com[/url]");

      I'm not sure exactly what you're trying to do here, but if you use header properly, it should work. Are you getting some kind of error such as headers already sent? if so, from php.net:

      Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.

      Cgraz

        well, I was trying with

        <?php

          if(1=1){
               header("Location:s.php");
          }else{header("Location:s.php");}?>

        as you suggested and still nothing,

          If it doesn't redirect, what does it do then? We need to know what the script is currently doing, to guesstimate the source of the problem.

          Diego

            if only I knew????

            to tell you the truth - nothing (just white site without anytking and no errors)

            sorry for mistake in my previous post (it can't be 1=1 of course...)

              something you might try is output buffering!
              check the man for ob_start and ob_end_flush and things like that!

              it's supposed to buffer all the output, and if headers are outputted, send the headers first, anyway
              (but I'm not shure about it, didn't use it yet...)

                sure it is sth wih settings, i put output_buffering = On in php.ini, but still nothing (of course if I run these scripts on other server it works fine!!!!!!!!)

                so will sb. help me with settings ....and now I will look closer to ob_start.....

                  these are my present settings:

                  ; Output buffering allows you to send header lines (including cookies) even
                  ; after you send body content, at the price of slowing PHP's output layer a
                  ; bit. You can enable output buffering during runtime by calling the output
                  ; buffering functions. You can also enable output buffering for all files by
                  ; setting this directive to On. If you wish to limit the size of the buffer
                  ; to a certain size - you can use a maximum number of bytes instead of 'On', as
                  ; a value for this directive (e.g., output_buffering=4096).
                  output_buffering = 4096

                  ; You can redirect all of the output of your scripts to a function. For
                  ; example, if you set output_handler to "ob_gzhandler", output will be
                  ; transparently compressed for browsers that support gzip or deflate encoding.
                  ; Setting an output handler automatically turns on output buffering.
                  output_handler =

                  ; Transparent output compression using the zlib library
                  ; Valid values for this option are 'off', 'on', or a specific buffer size
                  ; to be used for compression (default is 4KšŸ˜Ž
                  ;
                  ; Note: output_handler must be empty if this is set 'On' !!!!
                  ;
                  zlib.output_compression = Off

                  ; Implicit flush tells PHP to tell the output layer to flush itself
                  ; automatically after every output block. This is equivalent to calling the
                  ; PHP function flush() after each and every call to print() or echo() and each
                  ; and every HTML block. Turning this option on has serious performance
                  ; implications and is generally recommended for debugging purposes only.
                  implicit_flush = Off

                  ; Whether to enable the ability to force arguments to be passed by reference
                  ; at function call time. This method is deprecated and is likely to be
                  ; unsupported in future versions of PHP/Zend. The encouraged method of
                  ; specifying which arguments should be passed by reference is in the function
                  ; declaration. You're encouraged to try and turn this option Off and make
                  ; sure your scripts work properly with it in order to ensure they will work
                  ; with future versions of the language (you will receive a warning each time
                  ; you use this feature, and the argument will be passed by value instead of by
                  ; reference).
                  allow_call_time_pass_reference = Off

                    michalopek100, you do relise that you are making a loop as such and you would not relise the page has reloaded? it does work its just that its to fast for you to see its not like there is a delay its instant
                    also you neeed to exit; sometimes when using header()
                    so you just srick exit; under your header function

                      i had a similar problem a few months ago - its coz i had a space or small gap before i wrote the header(). header() must go before anything is written to the screen

                      eg: (i have put a to represent space)

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

                      that wont work because once the space has been sent, no headers can be sent. check ur code - most likely the very first character.

                      and you should notice it redirecting you back to 1.php because you will see the url in the address bar change to connect.php then back to 1.php - also the page 1.php will appear to reload

                      Hope that helps
                      - Matt

                        this is not the same, because I know this problem, and have made everythig that the gap were not there

                        I only suppose that this problem is not even php.ini settings but Apache , but I don't know how to solve it.

                        I've checked my script and it works on the over servers but not mine.....
                        But thx,
                        any Apache gurus?

                          this problem is not apaches its a php problem unless you are running mod_php which if yo are i strongly suggest you get the real php

                            it's not a PHP problem. neither Apache's one.
                            if i'm not mistaken HTTP protocol requires full complete URLs to be used in "Location" header.
                            so, try to use complete http://www.host.com/dir/script.php form of an URL and this should work out.

                              what do you mean?
                              ????this problem is not apaches its a php problem unless you are running mod_php which if yo are i strongly suggest you get the real php?????

                              hm.... I was just wondering why nobody knows how to repair it. Everybody is trying to show his own suggestions about gaps, urls and probobly in future about capital "L" but I tell you once more: my script is ok - you don,t have to explain me how to change it - I can go to PHP.net and can find original solutions (which neither doesn't work on my server)

                              the problem is with my server:
                              Apache 1.3.22
                              PHP 4.2.3
                              Windows 2002

                              Anybody will help me with settings???

                                The Location: tag begins with a capital L and ends with a colon followed by a space. The value that follows it is required by the HTTP standard to be single absolute URI.

                                Correct example:

                                Location: http://www.phpbuilder.com/file.html

                                Notice the space between "Location:" and the URI.

                                Incorrect:
                                Location:http://www.phpbuilder.com/file.html
                                location: http://www.phpbuilder.com/file.html
                                Location: www.phpbuilder.com/file.html
                                Location: file.html

                                If you mangle it, leave out spaces, omit the protocol and the server name, et cetera, the Web server may or may not clean up your mess and the Web browser client may or may not accept the results. But before you worry about php.ini settings, get your code right.

                                  and this previous post was about capital "L" and .....what about Apache...

                                    a month later

                                    This is what the PHP manual says, although I have had success with
                                    header ("Location: $nukeurl/index.php"); exit();
                                    I prefer to do as they suggest and put
                                    header ("Location: [url]http://[/url]".$SERVER['HTTP_HOST'].dirname($SERVER['PHP_SELF'])."/index.php"); exit();

                                    Note: HTTP/1.1 requires an absolute URI as argument to Location: including the scheme, hostname and absolute path, but some clients accept relative URIs. You can usually use $SERVER['HTTP_HOST'], $SERVER['PHP_SELF'] and dirname() to make an absolute URI from a relative one yourself:

                                      Write a Reply...