probably simple solution to parse error

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
pEtErB
Forum Newbie
Posts: 3
Joined: Thu Nov 11, 2004 3:34 am

probably simple solution to parse error

Post by pEtErB »

Forgive this simple question from a newbie. It is probably so simple that the answer isn't in any of the existing forums. (I did check.) I inserted a piece of javascript into a php file, and when I call the script in the usual manner :
<script language="JavaScript" type="text/JavaScript">
my browser returns the following error:
Parse error: parse error, expecting `','' or `';'' in [FILENAME] on line [THISLINE}

Would someone please tell me how to invoke this script without getting this error? Thanks.
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

can you give us the code?
pEtErB
Forum Newbie
Posts: 3
Joined: Thu Nov 11, 2004 3:34 am

Post by pEtErB »

The whole thing? It's fairly big... basically, it's a php-based guestbook, and there is all kinds of authentication stuff. I am trying to use javascript to block certain email addresses from spamming my guestbook (promoting online gambling in Russia, etc.), so I put the javascript in the 'header' part of the guestbook (where I have already successfully put CSS, etc.). The js creates an array of blocked email addresses, and the js is then called by an onBlur event in the form the visitor fills out. Is this enough info, or should I include more code? Basically, I don't know the proper syntax.
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Well the error is telling you what is wrong. Its a parse error with php on the line it mentions in the file it says. Open up that file and have a look at the line it says. You may see the error straight away - probably missing a closing quote on something. Also check the line above as it maybe an error carried on from that line.

If your still stuck then post use the few lines of code on and around where it says the error is.
pEtErB
Forum Newbie
Posts: 3
Joined: Thu Nov 11, 2004 3:34 am

Post by pEtErB »

I solved the problem. As I suspected, it was a syntax problem. As we all know, php uses quotes, so if you want to ignore quotes and treat them like a string, you have to precede them with a backslash. I had copy-n-pasted my js code, and neglected to think of this issue. Thanks for your replies. I would move this topic to the 'solved' pile if I knew how.
Post Reply