phpvariableshttp-redirectmeta-tags

Using a variable value in <meta http-equiv="refresh" content=" url="/>?


Alright, in my PHP file I need the program to make a redirect from the middle of a big if-loop. I can successfully use the command to redirect to another page when I manually set the seconds, like:

echo '<meta http-equiv="refresh" content="2; url='www.google.com'"/>';

However, in the background I run a SQL-query, from where I get the refresh "rate". That value I have passed into a variable, and I want to use the variable value like this:

echo '<meta http-equiv="refresh" content="'.$refreshvalue.'; url='www.google.com'"/>';

I don't know where is the problem. In my program, everything works out as intended when I set the value manually, but when I try to get the value from the variable, the program simply does not execute the redirect.

The query gives me the correct value, and I can pass it to variable. But there's something wrong in the syntax, I assume. I've tried couple of other ways.

Also, if you have a simple alternative to using 'meta' or php function header(), I'm more than interested to hear about it.

Is my syntax wrong, or what's up here?


Solution

  • Are you sure, $refreshvalue contains an valid integer value and all quotes are correctly escaped? It should look something like this

    $refreshvalue = 2;
    echo '<meta http-equiv="refresh" content="' . $refreshvalue . '; url=\'http://www.google.com\'"/>';