variable link redirect issue - Please help

Discussion in 'PHP' started by adamk1, Oct 23, 2007.

  1. #1
    Hi can anybody see a problem with this script i am getting: Parse error: syntax error, unexpected '"' in /home/public_html/test.php on line 6?? I highlighted line 6 in red,

    <?php
    header( 'Location: <?php
    mysql_connect("localhost", "username", "password") or die(mysql_error());
    mysql_select_db("links") or die(mysql_error());
    $id = $_GET["id"];
    $linkQuery = mysql_query("SELECT * FROM `links` WHERE `id`='".$id."' LIMIT 1") or die(mysql_error());
    $link = mysql_fetch_array($linkQuery);
    echo "".$link['link'] . "";
    ?>' ) ;
    ?>

    I am trying to have a variable link as a redirect
     
    adamk1, Oct 23, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    What are you trying to do? The code doesn't make sense.


    Try it this way.
    
    <?php
    
    mysql_connect("localhost", "username", "password") or die(mysql_error());
    mysql_select_db("links") or die(mysql_error());
    $id = $_GET["id"];
    $linkQuery = mysql_query("SELECT * FROM `links` WHERE `id`='".$id."' LIMIT 1") or die(mysql_error());
    $link = mysql_fetch_array($linkQuery);
    header('Location: ' . $link['link']);
    ?>
    
    PHP:
     
    nico_swd, Oct 23, 2007 IP
  3. adamk1

    adamk1 Active Member

    Messages:
    110
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #3
    oh you know passing the time trying a few new random things with link structure & seo, thanks that works great!
     
    adamk1, Oct 23, 2007 IP