Quick PHP script question

Discussion in 'PHP' started by jukebox9988, May 20, 2007.

  1. #1
    I'm trying to add the following script to my wordpress blog, however I keep getting a parse error. Any ideas on what's wrong here?

    <?php 
    if ( (is_single('121')) || (is_single('409')) )
    {
    echo '<a href="http://www.investortrip.com/ccount/click.php?id=23" target="_top">
    <img src="http://www.lduhtrp.net/image-2160939-10468653" width="336" height="280" alt="" border="0" /></a>';
    }
    else {
    <?php 
    if (preg_match('/^http:\/\/(\w+\.)?(google|msn|yahoo|aol)\./',$_SERVER['HTTP_REFERER']) == 1) { ?>
    <?php include 'adsense-combo.php'; ?>
    <?php } ?>
    } ?>
    Code (markup):
    Thanks
     
    jukebox9988, May 20, 2007 IP
  2. hasbehas

    hasbehas Well-Known Member

    Messages:
    726
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    190
    #2



    
    <?php 
    if ( (is_single('121')) || (is_single('409')) )
    {
    print '<a href="http://www.investortrip.com/ccount/click.php?id=23" target="_top">
    <img src="http://www.lduhtrp.net/image-2160939-10468653" width="336" height="280" alt="" border="0" /></a>';
    }
    elseif (preg_match('/^http:\/\/(\w+\.)?(google|msn|yahoo|aol)\./',$_SERVER['HTTP_REFERER']) == 1) 
    { 
    include 'adsense-combo.php'; 
    }
    ?>
    
    PHP:
    I have not tested this but this is the way it should be. Your mistake was to not end php tag. and restarting without ending it.
     
    hasbehas, May 20, 2007 IP
  3. jukebox9988

    jukebox9988 Well-Known Member

    Messages:
    607
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    140
    #3
    Thanks so much. I really want to learn more PHP so I can avoid those mistakes in the future. Where can I find a thorough tutorial?
     
    jukebox9988, May 20, 2007 IP
  4. hasbehas

    hasbehas Well-Known Member

    Messages:
    726
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    190
    #4
    hasbehas, May 20, 2007 IP