how to get $link working?

Discussion in 'PHP' started by promotingspace.net, Aug 8, 2007.

  1. #1
    hi
    i'm again with parse errors. How should the code below be to work?
    <?php 
    $link="http://adsense.com/clicks.php";
    
    ?>
    <a href=<? php $link  ?> > <td bgcolor="#FFFFFF">
    <font color="#008000" onmouseover=" " > title  </font><br>
    <font color="#008000" >description</font><br>
    <font color="#008000" >  displayurl</font>
    </td></a>
    
    PHP:

     
    promotingspace.net, Aug 8, 2007 IP
  2. JZWolf

    JZWolf Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    delete the space between '<?' and 'php'
     
    JZWolf, Aug 8, 2007 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    And add an "echo".
     
    nico_swd, Aug 9, 2007 IP
  4. Jona

    Jona Well-Known Member

    Messages:
    319
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    #4
    This code works :)

    
    <?$link="http://adsense.com/clicks.php";?>
    <a href="<?print $link;?>"> 
     <td bgcolor="#FFFFFF">
      <font color="#008000" onmouseover=" ">title</font><br>
      <font color="#008000">description</font><br>
      <font color="#008000">displayurl</font>
     </td>
    </a>
    
    Code (markup):
    and this also ...

    
    <?$link="http://adsense.com/clicks.php";?>
    <a href="<?print $link;?>"> 
     <td bgcolor="#FFFFFF">
      <font color="#008000" onmouseover=" ">title</font><br>
      <font color="#008000">
       description<br>
       displayurl
      </font>
     </td>
    </a>
    
    Code (markup):
     
    Jona, Aug 9, 2007 IP
  5. daman371

    daman371 Peon

    Messages:
    121
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    It isn't all the way proper though.

    <?php
    $link="http://adsense.com/clicks.php";
    ?>
    <a href="<?php print $link;?>"> 
     <td bgcolor="#FFFFFF">
      <font color="#008000" onmouseover=" ">title</font><br>
      <font color="#008000">
       description<br>
       displayurl
      </font>
     </td>
    </a>
    Code (markup):
    or

    
    <?php
    $link="http://adsense.com/clicks.php";
    ?>
    <a href="<?php echo $link;?>"> 
     <td bgcolor="#FFFFFF">
      <font color="#008000" onmouseover=" ">title</font><br>
      <font color="#008000">
       description<br>
       displayurl
      </font>
     </td>
    </a>
    Code (markup):
     
    daman371, Aug 11, 2007 IP
  6. hasan_889

    hasan_889 Banned

    Messages:
    303
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Your can write this way

    
    <?=$link?>
    
    PHP:
    to print any variable
     
    hasan_889, Aug 11, 2007 IP
  7. daman371

    daman371 Peon

    Messages:
    121
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    It's not proper though.
     
    daman371, Aug 12, 2007 IP
  8. void

    void Peon

    Messages:
    119
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #8
    What do you mean by "not proper"?
     
    void, Aug 12, 2007 IP
  9. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #9
    It's not proper because this method needs short tags to be enabled in php.ini, and it can be disabled, which would it prevent from working.
     
    nico_swd, Aug 12, 2007 IP
  10. void

    void Peon

    Messages:
    119
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #10
    I know that, but I still wouldn't say it's "not proper" though. Considering the page is mostly HTML, it's more readable than using
    <a href="<?php print $link;?>">
    HTML:
     
    void, Aug 12, 2007 IP
  11. daman371

    daman371 Peon

    Messages:
    121
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Exactly what I mean.
     
    daman371, Aug 12, 2007 IP