Parse error: syntax error, unexpected T_STRING

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ruchka
    New Member
    • Feb 2010
    • 4

    Parse error: syntax error, unexpected T_STRING

    Hi,

    Just found this forum and it looks like a wealth of info!

    I'm not a coder and have a problem with the following brief bit of code (reportedly on line 22):

    Code:
    <?php
    $d = $_GET["d"];
    $m = $_GET["m"];
    $y = $_GET["y"];
    
    $d = (int) $d;
    $m = (int) $m;
    $y = (int) $y;
    
    $curr = time();
    
    $olddt = mktime(0,0,0,$m,$d,$y);
    
    $ddiff = $curr - $olddt;
    $fulldays = floor($ddiff/(60*60*24));
    
    if ($fulldays < 2) { // Change 3 to however many days you want the link to last
    	$bannerAd[1] = 'http://www.mysite.com’;
      	
    	$adCount = count($bannerAd);
    	$randomAdNumber = mt_rand(1, $adCount);
            header('Location: ' . $bannerAd[$randomAdNumber]);
    }
    else {
    	header('Location:http://www.mysite2.com/');
    }
    ?>
    I cannot find the problem. If anyone can help it would be super appreciated.

    Thanks

    Ruchka
    Last edited by Dormilich; Feb 9 '10, 11:33 AM. Reason: Please use [code] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    is $bannerAd defined anywhere?

    Comment

    • ruchka
      New Member
      • Feb 2010
      • 4

      #3
      Thanks for responding Dormilich.

      The entire code is pasted above. I have no other codes or definitions anywhere else.

      As far as I know it could be defined in line 18:

      $bannerAd[1] = 'http://www.mysite.com’ ;

      But that is just a guess.
      Last edited by ruchka; Feb 9 '10, 12:06 PM. Reason: add more info

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        line #18, the string is not closed (a right single quotation mark is different from an apostrophe). therefore the first ' on line 22 is closing the string and PHP expects a . or ; after that.

        Comment

        • ruchka
          New Member
          • Feb 2010
          • 4

          #5
          Wow OK I see that and I made the change to line #18:

          now it is $bannerAd[1] = 'http://www.mysite.com' ;

          but I am still getting the same error. Weird...

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            well, I can’t see any syntax errors. then you can only comment out lines, maybe you find something this way.

            Comment

            • ruchka
              New Member
              • Feb 2010
              • 4

              #7
              you mean put

              //

              before code lines and see what happens?

              I will try that. Thanks for you time and help, its much appreciated!

              Comment

              • Markus
                Recognized Expert Expert
                • Jun 2007
                • 6092

                #8
                Post the revised code along with the full error string.

                Comment

                Working...