Can't figure out what's wrong with my code?

Discussion in 'PHP' started by xDemevenx, Apr 11, 2010.

  1. #1
    Hello,

    I'm pretty new to php, and I've decided to make a ad banner rotator for my practice site in class. This looks similar to other php rotator scripts, but I can't really see what's the error. All I receive is

    Parse error: syntax error, unexpected T_STRING on line 7

    Any help for a newbie would be greatly appreciated =)

    <div class="headadvert_468x60">
    
    	<?php
    
    $bannerCounter = 2;
    
    $bannerCode[$bannerCounter] = ‘<a href="http://www.example.com/" target="5" onmouseover="window.status='http://www.example.com/';return true;" onmouseout="window.status=' ';return true;">
    <img src="http://www.example.com/" width="468" height="60" alt="Random wording here" border="0"/></a>‘;
    $bannerCounter++;
    
    $bannerCode[$bannerCounter] = ‘<a href="http://www.example.com/" target="5" onmouseover="window.status='http://www.example.com/';return true;" onmouseout="window.status=' ';return true;">
    <img src="http://www.example.com/" width="468" height="60" alt="Random Wording Here!" border="0"/></a>‘;
    $bannerCounter++;
    
    $bannerAdTotals = $bannerCounter – 1;
    if($bannerAdTotals>1)
    {
    mt_srand((double)microtime() * 1234567);
    $bannerPicked = mt_rand(1, $bannerAdTotals);
    }
    else
    {
    $bannerPicked = 1;
    }
    $bannerAd = $bannerCode[$bannerPicked];
    
    echo $bannerAd;
    
    ?>
    
    </div>
    PHP:

     
    xDemevenx, Apr 11, 2010 IP
  2. Sbhedges

    Sbhedges Peon

    Messages:
    57
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    [Forget, won't work, sorry]
     
    Last edited: Apr 11, 2010
    Sbhedges, Apr 11, 2010 IP
    xDemevenx likes this.
  3. xDemevenx

    xDemevenx Well-Known Member

    Messages:
    546
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    130
    #3
    Thanks for the try though =) appreciate it
     
    xDemevenx, Apr 11, 2010 IP
  4. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #4
    <div class="headadvert_468x60">
    
        <?php
    
    $bannerCounter = 2;
    
    $bannerCode[$bannerCounter] = '<a href="http://www.example.com/" target="5" onmouseover="window.status=\'http://www.example.com/\';return true;" onmouseout="window.status=\' \';return true;">
    <img src="http://www.example.com/" width="468" height="60" alt="Random wording here" border="0"/></a>';
    
    $bannerCounter++;
    
    $bannerCode[$bannerCounter] = '<a href="http://www.example.com/" target="5" onmouseover="window.status=\'http://www.example.com/\';return true;" onmouseout="window.status=\' \';return true;">
    <img src="http://www.example.com/" width="468" height="60" alt="Random Wording Here!" border="0"/></a>';
    $bannerCounter++;
    
    $bannerAdTotals = $bannerCounter – 1;
    if($bannerAdTotals>1)
    {
    mt_srand((double)microtime() * 1234567);
    $bannerPicked = mt_rand(1, $bannerAdTotals);
    }
    else
    {
    $bannerPicked = 1;
    }
    $bannerAd = $bannerCode[$bannerPicked];
    
    echo $bannerAd;
    
    ?>
    
    </div>
    PHP:
    Escape your single quotes, with a backslash.
     
    danx10, Apr 11, 2010 IP
    xDemevenx likes this.
  5. xDemevenx

    xDemevenx Well-Known Member

    Messages:
    546
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    130
    #5
    Tried it out, thanks =) Still needs a bit modification on my end but it fixed things here and there. Thanks +rep
     
    xDemevenx, Apr 11, 2010 IP