Parse error: parse error, unexpected $

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
conundrum
Forum Newbie
Posts: 15
Joined: Sun Jun 29, 2003 12:18 pm
Location: Ontario, Canada

Parse error: parse error, unexpected $

Post by conundrum »

Hi Guys,

I have a page with about 600 lines of code. I don't think you ned to see it all. I get the following message when I try to run it:

Parse error: parse error, unexpected $ in E:\www\quickResults.php on line 605

Line 605 is just </html> I closed off the php stuff a few lines above. I think it is just something stupid like a missed semicolon or a quote or something but haven't been able to spot it. Any suggestions as to where I should be looking? Would it be a semicolon or quote or is it something all-together different? Seems to me I ran into this a while ago, but don't remember what fixed it :oops:
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

welll. there could be more than just a semicolon. and we problaby don't need the complete code


look at the last function you have, look for an error there.

if you can't find it, show us the block of code

edit: or link to the source for those that actually wanna see it all,....
conundrum
Forum Newbie
Posts: 15
Joined: Sun Jun 29, 2003 12:18 pm
Location: Ontario, Canada

Post by conundrum »

Wow!

You are fast. Here is a link to the code in txt format.

http://www.cottages.net/snagme/quickResults.txt

Long story short.... I have been asked to take an ASP site and convert it to PHP. I am somewhat new at PHP (I took some PHP and lots of JSP in college) I have seen this problem before and it was always something stupid that I just didn't spot.

I use textpad to edit code. Is there a better IDE which has debugging abilities? That would likely save me some headaches.

Thanks in advance for your help, if you can indeed see anything obvious.
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

two PROGRAMMING editors that you should look at. both are FREE and both are opensource. i debug with printlines. so i don't know what the debugger is like, but they both have one. they also have the gcc as a plug in, which is really nice.
emacs: http://www.gno.org/
xemacs: http://www.xemacs.org/

there's some other goodies it has. i don't use textpad, so i don't know.. does it do pretty printing/line indenting and syntax highlighting? what about parenthesis matching?

both emacs and xemacs do those. i've used them both for php, html, c, c++, java, perl, lisp and scheme

i don't see it. but i do have another piece of advice as well, instead of making those long lists, use this function (in an include) and you can plug in one variable that is the entire list.. also makes it easier to adjust the list since you'll use an array...

Code: Select all

<?
function array_to_options($array, $selected){
  echo "in ato, selected: $selected; array: $array <br />"; # debug
  $optlist=''; # make an empty string
  foreach($array as $key=>$value){
    if($selected==$key){ # if this is the first time it wont match, so we don't need to care if it's set
      $optlist=$optlist."<option value="$key" selected>$value</option>";
    }else{
      $optlist=$optlist."<option value="$key">$value</option>";
    }
  }
  return $optlist;
}
?>
conundrum
Forum Newbie
Posts: 15
Joined: Sun Jun 29, 2003 12:18 pm
Location: Ontario, Canada

Post by conundrum »

Thanks for the function, I'll try it. I was thinking that after I got the ASP switched over to PHP I'd try to shorten up some of that stuff.

Textpad does have syntax highlighting so braces are one colour, brackets are another, html is another etc.... It is pretty good, but I'd like to try something else as well. Thanks for the links.

So... I believe that when I had this problem before it had to do with some sort of hidden new line or something funny. I opened the file in dreamweaver at one point and I wonder if it didn't put some sort of hidden symbol or some sort of white space or something in there? Sounds weird, but I can't think of anything else.
Post Reply