Parse error: syntax error, unexpected T_VARIABLE

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Brigitte Smith
    New Member
    • Jul 2010
    • 7

    #1

    Parse error: syntax error, unexpected T_VARIABLE

    I'm trying to make an image map and when I click on any part of it now it gives "Parse error: syntax error, unexpected T_VARIABLE in /usr/data2/hosted/angelauset/IMGMAPONE/map.php on line 11"


    Code:
    <?PHP
    
    /* Gaia Image Map Go-er
    Rudolph J Heuser (Jakobo on GaiaOnline.com
    Modified: John T Wu (borobdin on GaiaOnline.com)
    */
    
    require_once("imagemap.php")
    
    // new imageMap
    $myImageMap = new imageMap()
    
    // AGG
    $area = new Rect(16, 482, 90, 407, "http://www.gaiaonline.com/forum/chatterbox/anonymous-gift-giving-first-new-thread-of-10/t.62886585_1")
    $myImageMap->addToMap($area)
    
    
    $myImageMap->setDefaultURL("http://www.gaiaonline.com/profiles/4170512?_gaia_t_=5414")
    
    // capture X and Y from query string
    $x_and_y = $_SERVER["QUERY_STRING"]
    $x_and_y = explode(",",$x_and_y)
    $inX = $x_and_y[0]
    $inY = $x_and_y[1]
    unset($x_and_y)
    
    // echo $inX. "," . $inY;
    $myImageMap->testMap($inX, $inY)
    
    
    ?>
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    PHP requires that expressions end with a semi-colon.

    Code:
    // Bad code - notice: no semi-colon.
    $name = 'Mark'
    $age  = 19
    
    // Good code - with semi-colon.
    $name = 'Mark';
    $age  = 19;
    Mark.

    Comment

    • Brigitte Smith
      New Member
      • Jul 2010
      • 7

      #3
      Originally posted by Markus
      PHP requires that expressions end with a semi-colon.

      Code:
      // Bad code - notice: no semi-colon.
      $name = 'Mark'
      $age  = 19
      
      // Good code - with semi-colon.
      $name = 'Mark';
      $age  = 19;
      Mark.
      I added a semi-colon to the end of line 11 but I'm still getting that same error
      EDIT: Now I'm getting the same error on line 15.

      Code:
      <?PHP
       
      /* Gaia Image Map Go-er
      Rudolph J Heuser (Jakobo on GaiaOnline.com
      Modified: John T Wu (borobdin on GaiaOnline.com)
      */
        
      require_once("imagemap.php");
        
      // new imageMap
      $myImageMap = new imageMap();
        
      // AGG
      $area = new Rect(16, 482, 90, 407, "http://www.gaiaonline.com/forum/chatterbox/anonymous-gift-giving-first-new-thread-of-10/t.62886585_1")
      $myImageMap->addToMap($area);
        
        
      $myImageMap->setDefaultURL("http://www.gaiaonline.com/profiles/4170512?_gaia_t_=5414");
        
      // capture X and Y from query string
      $x_and_y = $_SERVER["QUERY_STRING"]
      $x_and_y = explode(",",$x_and_y)
      $inX = $x_and_y[0]
      $inY = $x_and_y[1]
      unset($x_and_y)
        
      // echo $inX. "," . $inY;
      $myImageMap->testMap($inX, $inY)
        
        
      ?>

      Comment

      • zorgi
        Recognized Expert Contributor
        • Mar 2008
        • 431

        #4
        Originally posted by Brigitte Smith
        I added a semi-colon to the end of line 11 but I'm still getting that same error
        EDIT: Now I'm getting the same error on line 15.

        Code:
        <?PHP
         
        /* Gaia Image Map Go-er
        Rudolph J Heuser (Jakobo on GaiaOnline.com
        Modified: John T Wu (borobdin on GaiaOnline.com)
        */
          
        require_once("imagemap.php");
          
        // new imageMap
        $myImageMap = new imageMap();
          
        // AGG
        $area = new Rect(16, 482, 90, 407, "http://www.gaiaonline.com/forum/chatterbox/anonymous-gift-giving-first-new-thread-of-10/t.62886585_1")
        $myImageMap->addToMap($area);
          
          
        $myImageMap->setDefaultURL("http://www.gaiaonline.com/profiles/4170512?_gaia_t_=5414");
          
        // capture X and Y from query string
        $x_and_y = $_SERVER["QUERY_STRING"]
        $x_and_y = explode(",",$x_and_y)
        $inX = $x_and_y[0]
        $inY = $x_and_y[1]
        unset($x_and_y)
          
        // echo $inX. "," . $inY;
        $myImageMap->testMap($inX, $inY)
          
          
        ?>
        To quote Markus: "PHP requires that expressions end with a semi-colon."

        EVERY EPRESSION

        Comment

        • Brigitte Smith
          New Member
          • Jul 2010
          • 7

          #5
          Originally posted by zorgi
          To quote Markus: "PHP requires that expressions end with a semi-colon."

          EVERY EPRESSION
          What exactly constitutes an expression? How do I know where to put semi-colons? There IS a semi-colon in the line where it says that there is an error.

          Comment

          • zorgi
            Recognized Expert Contributor
            • Mar 2008
            • 431

            #6
            What are expressions!?

            You should learn those basics. Here is the link that will explain expressions AND here is another interesting link for you

            P.S. Check the line before :)

            Comment

            • Brigitte Smith
              New Member
              • Jul 2010
              • 7

              #7
              Originally posted by zorgi
              What are expressions!?

              You should learn those basics. Here is the link that will explain expressions AND here is another interesting link for you

              P.S. Check the line before :)
              Ya, I think it's pretty obvious I just need an interchangable code where I can alter the rectangle numbers and never have to write one again. I'm terrible at coding even HTML. The link you sent made my head spin. >.< Thank you for the assistance though. Every time I fix one error more come up.

              Comment

              • Brigitte Smith
                New Member
                • Jul 2010
                • 7

                #8
                Now I'm getting "Notice: Undefined offset: 1 in C:\Program Files (x86)\EasyPHP-5.3.2i\www\map. php on line 33". Adding a ; didn't fix it. I looked it up, but I have no idea what the people are talking about when they're telling other people how to fix this error.

                Code:
                <?PHP
                /* Gaia Image Map Go-er
                Rudolph J Heuser (Jakobo on GaiaOnline.com
                Modified: John T Wu (borobdin on GaiaOnline.com)
                */
                
                require_once("imagemap.php");
                
                // new imageMap
                $myImageMap = new imageMap();
                
                
                // AGG
                $area = new Rect(16, 482, 90, 407, "http://www.gaiaonline.com/forum/chatterbox/anonymous-gift-giving-first-new-thread-of-10/t.62886585_1");
                $myImageMap->addToMap($area);
                
                
                // Quest
                $area = new Rect(113, 483, 186, 410, "http://www.gaiaonline.com/forum/chatterbox/anonymous-gift-giving-first-new-thread-of-10/t.62886585_1");
                $myImageMap->addToMap($area);
                
                
                // Art
                $area = new Rect(212, 883, 290, 409, "http://www.gaiaonline.com/forum/chatterbox/anonymous-gift-giving-first-new-thread-of-10/t.62886585_1");
                $myImageMap->addToMap($area);
                
                $myImageMap->setDefaultURL("");
                
                // capture X and Y from query string
                $x_and_y = $_SERVER["QUERY_STRING"];
                $x_and_y = explode(",",$x_and_y);
                $inX = $x_and_y[0];
                $inY = $x_and_y[1];
                unset($x_and_y);
                
                // echo $inX. "," . $inY;
                $myImageMap->testMap($inX, $inY);
                
                ?>

                Comment

                • Markus
                  Recognized Expert Expert
                  • Jun 2007
                  • 6092

                  #9
                  That error is telling you that index 1 does not exist in the $x_and_y array.

                  Code:
                  // Consider:
                  $array = array(0 => 'Mark');
                  print $array[1];
                  // Doing this causes a warning because that offset (1) does not exist.
                  What does the output of
                  Code:
                  $x_and_y = explode(',', $x_and_y);
                  var_dump($x_and_y);
                  reveal?

                  Comment

                  • Brigitte Smith
                    New Member
                    • Jul 2010
                    • 7

                    #10
                    Originally posted by Markus
                    That error is telling you that index 1 does not exist in the $x_and_y array.

                    Code:
                    // Consider:
                    $array = array(0 => 'Mark');
                    print $array[1];
                    // Doing this causes a warning because that offset (1) does not exist.
                    What does the output of
                    Code:
                    $x_and_y = explode(',', $x_and_y);
                    var_dump($x_and_y);
                    reveal?
                    I have no idea what you just asked.

                    Comment

                    • TheServant
                      Recognized Expert Top Contributor
                      • Feb 2008
                      • 1168

                      #11
                      First of all, adding the semi-colon did fix the original problem, and after that, another problem was shown. Your latest error is completely different from the first.

                      Check $x_and_y. "offset is undefined" means that the requested array key has not been set. If your error is in fact on line 33, then it means the array $x_and_y, does not have a key of '1': $x_and_y[1]
                      Echo your $_SERVER["QUERY_STRI NG"] and check that it has what you want.

                      (^ what Markus said)
                      Last edited by TheServant; Jul 9 '10, 10:58 AM. Reason: Too slow :(

                      Comment

                      • Brigitte Smith
                        New Member
                        • Jul 2010
                        • 7

                        #12
                        Originally posted by TheServant
                        First of all, adding the semi-colon did fix the original problem, and after that, another problem was shown. Your latest error is completely different from the first.

                        Check $x_and_y. "offset is undefined" means that the requested array key has not been set. If your error is in fact on line 33, then it means the array $x_and_y, does not have a key of '1': $x_and_y[1]
                        Echo your $_SERVER["QUERY_STRI NG"] and check that it has what you want.

                        (^ what Markus said)
                        I still don't understand. What part of the code do I change? And what do I change it to? If "$inY = $x_and_y[1];" is wrong, what is right?
                        Edit: Ok, I fixed that line, but now I get "Parse error: syntax error, unexpected T_UNSET in C:\Program Files (x86)\EasyPHP-5.3.2i\www\map. php on line 34"
                        Edit: I replaced that line with
                        Code:
                        $x_and_y = null;
                        echo $x_and_y;
                        and that error went away.
                        Now I have "Notice: Undefined variable: inY in C:\Program Files (x86)\EasyPHP-5.3.2i\www\map. php on line 38". Since I removed the inY part of the code, what do I put there?

                        Comment

                        • TheServant
                          Recognized Expert Top Contributor
                          • Feb 2008
                          • 1168

                          #13
                          We're not saying to get rid of it. What we're saying is:
                          Code:
                          $x_and_y = $_SERVER["QUERY_STRING"];
                          $x_and_y = explode(",",$x_and_y);
                          Is not returning an array with two values. It is only returning a single value, which I am going to guess is because $_SERVER["QUERY_STRI NG"] does not contain a comma, which is what you're using for your explode. The rest is OK, you just need to get that explode line working.

                          Comment

                          Working...