I'm trying to use header like so

header('Location: http://www.example.com/');

but it doesn't work. I look in my address bar and it is still the address of the original file. But if I put something like

echo "yo";

it echos out the response. I don't get it, help???

    I recall that I had this problem once in my life as well, only to realize that for some reason my browser kept caching old pages.

    For a start try another browser.

      that didn't work, any other ideas?

        are you getting any errors at all?

        can we see a larger snippet of code since we all know the header() function, but aren't sure what else is going on?

          stolzyboy wrote:

          are you getting any errors at all?

          can we see a larger snippet of code since we all know the header() function, but aren't sure what else is going on?

          I can pm to both of you if you don't mind. I just don't want all my stuff on the net is all.

            TitanKing wrote:

            <?php
            header('Location: http://www.example.com/');
            ?>

            a Plain script like this should redirect, if not, there is something else wrong.

            that doesn't work either so there is something wrong. I don't quite get it but I PM'd it to both of you. Let me know what you think. (Oh, and feel free to test a little on the link I supplied as well to get an idea as to what it's doing.

              DKY wrote:

              I can pm to both of you if you don't mind. I just don't want all my stuff on the net is all.

              Do that, maybe I can sell your script on the black market 😉

                One thing is you must use your header as the very first line in your page. If there is any blank line or space ahead of your header code, then it will not work. I tried it and it worked fine as long as it was the first code at the very top of your page.

                  TitanKing wrote:

                  Do that, maybe I can sell your script on the black market 😉

                  There just are some links in there that I don't want public.

                    did you guys get that pm because it's not showing in my sent items on this forum.

                      i never received anything if you sent me anything...

                      just XXXXXX out the url's so we can see what's going on elsewhere in the script...

                      like stated earlier, there must be no html, whitespace, etc... before the header() call or it won't work OR you can use ob_start() as the FIRST line of code AFTER the initial <?php tags, then you can use header() wherever you'd like regardless of html or whitespace output

                      hth,
                      stolzyboy

                        ob_start();
                        worked. I just put it at the top of my page and I can use the header in my nested if! That's awesome! Thanks for the help!

                          then you must have had some output before that was causing an error, but the errors may be not turned on or the error_reporting level is set to 0

                            Write a Reply...