473,382 Members | 1,362 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 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 1680
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

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

Similar topics

8
by: Wescotte | last post by:
The error message Parse error: syntax error, unexpected $end in FILE on line X is one I run into frequently and I know the cause is I missed an ending quote. Is there an easy way to determine...
36
by: rhys | last post by:
My Gurus and Angels -- Please pardon this old-school programmer, only recently enlightened to open-source, having been trapped in the convenience of proprietary lingos for way too long. My...
3
by: SilvaZodiac | last post by:
Hi everyone, I'm still rather new to PHP code, and I have a syntax error. I've tried several different solutions, but it won't fix. It seems to suggest that I need a new bracket somewhere in the...
2
by: fburn | last post by:
I need some help with an error I'm getting using php 5.2.5 running on linux. I receive an error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or...
9
akohistani
by: akohistani | last post by:
I am having Parse error problem with my newly purchased Php upload script I have uploaded the script and I get the error below Parse error: syntax error, unexpected $end in URL/functions.php on...
3
paulrajj
by: paulrajj | last post by:
hi to all, i am getting syntax error on my code.. Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in D:\xampp\htdocs\Dummy\paulraj\matrim\exam.php on line 62 ...
10
by: benicio | last post by:
Parse error: syntax error, unexpected T_STRING, expecting '(' in C:\wamp\www\study_group\includes\functions.php on line 19 I got this error and this syntax is from 8 to 19th line. <?php ...
3
by: brkseven | last post by:
Looking for help with this Contact Form. The error is on line 1, but that' doesn't mean a lot, I think. In fact, a php syntax check passed it, but I was hoping for an easy syntax error, it looks...
3
by: CYNTHIA CUTRER | last post by:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> ...
2
by: Vicki Hendra | last post by:
Hi I am new to php fullstop I and colleagues have setup wordpress blogs for our local towns, giving the local businesses free advertisment. Part of the problem started when using wordpress...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.