Location rederict

I’m going crazy. I did this so many times and now it’s not working.

I have this line on a page:

header("Location: $url");

I tried to output the same thing on the page, without the redirect and it outputs what is set in $url.
But when I write that line, it doesn’t redirect. Am I doing something wrong with the " ?

That looks OK to me. It might be something to do with the larger context. What does happen at the moment? Can you post more code?

But when I write

<?php echo $url; ?>

The url is showing correct on the screen.

This code is working:

$url = $row_rs_band['url'];
echo $url;

This code is NOT working:

header("Location: $url");

The first thing is a code I placed to check if the output is correct.
Then when running the second one, I removed the first part, since there cannot be any output before a redirect.

I have no idea what I did now. I just wrote the code, uploaded the file and now it works.
Maybe an invisible space was inserted. Sometimes I’ve seen that when copying and pasting…

Two things to watch out for with header();

Do not output anything prior to calling it, not a space, new line, nothing.



on the line immediately below.

Turn on error_reporting when you spot this again.

OK, thats 3 things …