Forum Moderators: coopster

Message Too Old, No Replies

Parse Error, unexpected $

Not sure what I sould be looking for!

         

Spook

5:21 pm on Jul 30, 2004 (gmt 0)

10+ Year Member



Hi All.

I am getting the following error message:

Parse error: parse error, unexpected $ in /blah/blah/blah/blah/error.php on line 40

and the code is:

<?php
include ("includes/check_fields.php");
include ("includes/door_functions.php");

check_fields($style, $colour, $panelType, $height, $width); // Check and validate fields

if ($message!="")
{
echo "$message";
}
else
{
echo's Quantity, Colour, Width, Height, Type,
}
get_best_price($height, $width);//Get best "base price" from Dbase

get_range ($style);//Check which price range to use

calculate_price($range, $best_price);//Calcs actual price

echo $price;
echo $message;

exit;
?>
THIS IS LINE 40
I haven't a clue what I'm looking for, a stray $ character? A string? or something else maybe?

Never the less, I still can't find the problem!

Can someone point me in the right direction, I've tried out most of the error codes in the past, but this is a new one on me!

Thanks in advance.

Spook

ergophobe

5:31 pm on Jul 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I believe it's reaching the end of file unexpectedly.

Make sure all quotes are closed, braces matched, etc etc.

Tom

jatar_k

5:37 pm on Jul 30, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



shouldn't this line

echo's Quantity, Colour, Width, Height, Type,

be commented out?

//echo's Quantity, Colour, Width, Height, Type,

when i run a script for the first time and it is a couple hundred lines long and I get an error on the last line.

I usually bang my head on the keyboard a couple times and go for a coffee. You always have to go through the whole file, last changes first and keep going back until you find it.

fun

Spook

6:27 pm on Jul 30, 2004 (gmt 0)

10+ Year Member



Thanks for such a quick response [as always].

I didn't make it very clear, the line "echo's Quantity, Colour, Width, Height, Type," is where I deleted a chunk of code to keep the code post as short as possible - sorry.

I've spent most of the day going throught the code but can't spot anything, but its strange how your own mistakes are more difficult to see.

Think I will pass on the coffee and open a bottle of wine instead. Take another look tomorrow.

Thanks

Graham

Spook

9:11 am on Jul 31, 2004 (gmt 0)

10+ Year Member



Found it!

You were right it was a missing } but it took some finding.

Ironically, in the code I posted above, I spotted the missing brace and replaced it, thinking I had deleted it by mistake whilst "reducing" the code for purpose of the forum.

But why did the error message not say "parse error: missing "}"?

Anyway, panic over, that wine obviously did the trick!

Spook

vincevincevince

9:20 am on Jul 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try using something with good syntax highlighting, and quote/brace matching.

For *nix I recommend Kate (part of kde).
For win32 I recommend EditPlus 2.

dreamcatcher

12:42 pm on Jul 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



jEdit also has really good brace matching.

ergophobe

7:24 pm on Jul 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hehe. Yeah I'm always swearing at my editor (HAPEdit) saying "That stupid thing! The brace highlighting isn't working!" Fortunately, it's too polite to swear back!

Tom

Spook

2:30 pm on Aug 1, 2004 (gmt 0)

10+ Year Member



I've been trying Crimson Editor but I will have a look at the others you have suggested.

What I could really do with is one that sounds a Klaxon when I make a mistake! :lol:
Spook

bamz

2:14 am on Aug 16, 2004 (gmt 0)



Hi everyone,
I just wanted to say thankyou so much. I was having the exact same problem with an unexpected $ creating a parse error and couldn't find any $ which would be doing it. In the end it turned out that I had 3 (not one, not two, but three mind you - how did I miss those?) missing } - I suppose thats what you get when you cut and paste your code.
Thanks again, without this post I would never have fixed my problem.
Bamz

coopster

2:33 am on Aug 16, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Awesome. Glad to have you aboard, bamz! Welcome to WebmasterWorld :)