471,122 Members | 1,202 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,122 software developers and data experts.

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"


Expand|Select|Wrap|Line Numbers
  1. <?PHP
  2.  
  3. /* Gaia Image Map Go-er
  4. Rudolph J Heuser (Jakobo on GaiaOnline.com
  5. Modified: John T Wu (borobdin on GaiaOnline.com)
  6. */
  7.  
  8. require_once("imagemap.php")
  9.  
  10. // new imageMap
  11. $myImageMap = new imageMap()
  12.  
  13. // AGG
  14. $area = new Rect(16, 482, 90, 407, "http://www.gaiaonline.com/forum/chatterbox/anonymous-gift-giving-first-new-thread-of-10/t.62886585_1")
  15. $myImageMap->addToMap($area)
  16.  
  17.  
  18. $myImageMap->setDefaultURL("http://www.gaiaonline.com/profiles/4170512?_gaia_t_=5414")
  19.  
  20. // capture X and Y from query string
  21. $x_and_y = $_SERVER["QUERY_STRING"]
  22. $x_and_y = explode(",",$x_and_y)
  23. $inX = $x_and_y[0]
  24. $inY = $x_and_y[1]
  25. unset($x_and_y)
  26.  
  27. // echo $inX. "," . $inY;
  28. $myImageMap->testMap($inX, $inY)
  29.  
  30.  
  31. ?>
Jul 9 '10 #1
12 1486
Markus
6,050 Expert 4TB
PHP requires that expressions end with a semi-colon.

Expand|Select|Wrap|Line Numbers
  1. // Bad code - notice: no semi-colon.
  2. $name = 'Mark'
  3. $age  = 19
  4.  
  5. // Good code - with semi-colon.
  6. $name = 'Mark';
  7. $age  = 19;
  8.  
Mark.
Jul 9 '10 #2
@Markus
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.

Expand|Select|Wrap|Line Numbers
  1. <?PHP
  2.  
  3. /* Gaia Image Map Go-er
  4. Rudolph J Heuser (Jakobo on GaiaOnline.com
  5. Modified: John T Wu (borobdin on GaiaOnline.com)
  6. */
  7.  
  8. require_once("imagemap.php");
  9.  
  10. // new imageMap
  11. $myImageMap = new imageMap();
  12.  
  13. // AGG
  14. $area = new Rect(16, 482, 90, 407, "http://www.gaiaonline.com/forum/chatterbox/anonymous-gift-giving-first-new-thread-of-10/t.62886585_1")
  15. $myImageMap->addToMap($area);
  16.  
  17.  
  18. $myImageMap->setDefaultURL("http://www.gaiaonline.com/profiles/4170512?_gaia_t_=5414");
  19.  
  20. // capture X and Y from query string
  21. $x_and_y = $_SERVER["QUERY_STRING"]
  22. $x_and_y = explode(",",$x_and_y)
  23. $inX = $x_and_y[0]
  24. $inY = $x_and_y[1]
  25. unset($x_and_y)
  26.  
  27. // echo $inX. "," . $inY;
  28. $myImageMap->testMap($inX, $inY)
  29.  
  30.  
  31. ?>
Jul 9 '10 #3
zorgi
431 Expert 256MB
@Brigitte Smith
To quote Markus: "PHP requires that expressions end with a semi-colon."

EVERY EPRESSION
Jul 9 '10 #4
@zorgi
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.
Jul 9 '10 #5
zorgi
431 Expert 256MB
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 :)
Jul 9 '10 #6
@zorgi
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.
Jul 9 '10 #7
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.

Expand|Select|Wrap|Line Numbers
  1. <?PHP
  2. /* Gaia Image Map Go-er
  3. Rudolph J Heuser (Jakobo on GaiaOnline.com
  4. Modified: John T Wu (borobdin on GaiaOnline.com)
  5. */
  6.  
  7. require_once("imagemap.php");
  8.  
  9. // new imageMap
  10. $myImageMap = new imageMap();
  11.  
  12.  
  13. // AGG
  14. $area = new Rect(16, 482, 90, 407, "http://www.gaiaonline.com/forum/chatterbox/anonymous-gift-giving-first-new-thread-of-10/t.62886585_1");
  15. $myImageMap->addToMap($area);
  16.  
  17.  
  18. // Quest
  19. $area = new Rect(113, 483, 186, 410, "http://www.gaiaonline.com/forum/chatterbox/anonymous-gift-giving-first-new-thread-of-10/t.62886585_1");
  20. $myImageMap->addToMap($area);
  21.  
  22.  
  23. // Art
  24. $area = new Rect(212, 883, 290, 409, "http://www.gaiaonline.com/forum/chatterbox/anonymous-gift-giving-first-new-thread-of-10/t.62886585_1");
  25. $myImageMap->addToMap($area);
  26.  
  27. $myImageMap->setDefaultURL("");
  28.  
  29. // capture X and Y from query string
  30. $x_and_y = $_SERVER["QUERY_STRING"];
  31. $x_and_y = explode(",",$x_and_y);
  32. $inX = $x_and_y[0];
  33. $inY = $x_and_y[1];
  34. unset($x_and_y);
  35.  
  36. // echo $inX. "," . $inY;
  37. $myImageMap->testMap($inX, $inY);
  38.  
  39. ?>
Jul 9 '10 #8
Markus
6,050 Expert 4TB
That error is telling you that index 1 does not exist in the $x_and_y array.

Expand|Select|Wrap|Line Numbers
  1. // Consider:
  2. $array = array(0 => 'Mark');
  3. print $array[1];
  4. // Doing this causes a warning because that offset (1) does not exist.
  5.  
What does the output of
Expand|Select|Wrap|Line Numbers
  1. $x_and_y = explode(',', $x_and_y);
  2. var_dump($x_and_y);
  3.  
reveal?
Jul 9 '10 #9
@Markus
I have no idea what you just asked.
Jul 9 '10 #10
TheServant
1,168 Expert 1GB
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_STRING"] and check that it has what you want.

(^ what Markus said)
Jul 9 '10 #11
@TheServant
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
Expand|Select|Wrap|Line Numbers
  1. $x_and_y = null;
  2. 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?
Jul 9 '10 #12
TheServant
1,168 Expert 1GB
We're not saying to get rid of it. What we're saying is:
Expand|Select|Wrap|Line Numbers
  1. $x_and_y = $_SERVER["QUERY_STRING"];
  2. $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_STRING"] 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.
Jul 9 '10 #13

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.