1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Put url into variable?

Discussion in 'PHP' started by Amsterdam, Dec 11, 2011.

  1. #1
    Hi,

    I'm trying to add a paused re-direct to a URL using:

    
    echo '<META HTTP-EQUIV="Refresh" Content="3; URL=$mylink">';
    
    Code (markup):
    But whenever I give the variable '$mylink' a value such as 'http://forums.digitalpoint.com' it won't read the value and tries to re-direct to $mylink instead.

    What am I doing wrong?

    T
     
    Solved! View solution.
    Amsterdam, Dec 11, 2011 IP
  2. #2
    Take a look here: http://ca.php.net/types.string

    echo "<META HTTP-EQUIV=\"Refresh\" Content=\"3; URL=$mylink\">";
    PHP:
    echo '<META HTTP-EQUIV="Refresh" Content="3; URL=' . $mylink . '">';
    PHP:
     
    proactiv3, Dec 11, 2011 IP
  3. NIKOLO

    NIKOLO Member

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    46
    #3
    Everything is wrong in your code :(

    1. Never use upper case letter for tags in HTML (you must write <meta instead of <META)
    2. If it is refresh function, why u need enter url? Refresh means update same page, so you can leave it blank
    2. Use JavaScript for page refresh, as I remember refresh by meta tag is not supported some modern browsers

    There is JavaScript example for page refresh:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Page Refresh</title>
    <script language="javascript" type="text/javascript">
    <!--
    function autorefresh(timeout) {
    	setTimeout("location.reload(true);", (timeout*1000));
    }
    //-->
    </script>
    </head>
    
    <body onload="autorefresh(5);">
    
    Bla Bla Bla :)
    
    </body>
    </html>
    Code (markup):
    5 in body tag means seconds between refresh

    <body onload="autorefresh(5);">

    so if you change it to 10, page will be updated every 10 second.
     
    NIKOLO, Dec 11, 2011 IP
  4. yho_o

    yho_o Well-Known Member

    Messages:
    353
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    #4
    <?php
        $mylink = "http://www.google.com";
        echo "<META HTTP-EQUIV='Refresh' Content='3' URL='{$mylink}'>";
    ?>
    
    Code (markup):
    or use header for instant redirect:
    <?php    $mylink = "http://www.google.com";
        header("Location:{$mylink}");
    ?>
    
    Code (markup):
    hope it helps, gud luck
     
    yho_o, Dec 11, 2011 IP
  5. skyfe

    skyfe Active Member

    Messages:
    256
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    63
    #5
    Better use PHP built-in headers for redirecting/refreshing if you're afraid some browsers may not support your code.
     
    skyfe, Dec 13, 2011 IP
  6. ekaddu

    ekaddu Active Member

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #6
    some hostings allow headers to be sent only once. if this is the case with ur hosting then nikolos code would be useful.
     
    ekaddu, Dec 14, 2011 IP
  7. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #7
    That's a function of PHP, not the hosting. Using output buffering eliminates the problem.
     
    Rukbat, Dec 15, 2011 IP