[SOLVED] Error: Expected ;

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
jtc970
Forum Commoner
Posts: 38
Joined: Sun Jan 18, 2004 11:49 pm

Error: Expected ;

Post by jtc970 »

I tried many things but I cant get rid of this error in IE
Runtime Error: Expected ;

It happens when a string (for name or location) contains an open single quote '

here is the bit of code

Code: Select all

$DB->query("SELECT `name`,`id`,`map_location`,`location` FROM $mem_db where `map_location` != '' order by `name`") or print mysql_error();
    }
       
    
    ##start of the map coordinates 
    $htmlmap .= "<map NAME='pin_areas'>";
 
       while( $row = $DB->fetch_row() )&#123;
               
               $member2=$row&#1111;'name'];

                 if ($row&#1111;'location'])&#123;$member2=$member2.' - '.$row&#1111;'location'];&#125;
            	$mid=$row&#1111;'id'];
       		$cxcy=$row&#1111;'map_location'];       		
       		$mxmy=explode(',',$cxcy);
       		$locx=$mxmy&#1111;0];
		$locy=$mxmy&#1111;1];
		$locx2=$locx+6;
 		$locy2=$locy+8;
                
                ##continue the map coordinates
	 	
	 	$htmlmap .= "<area SHAPE=RECT COORDS='$locx,$locy,$locx2,$locy2';  href='index.php?showuser=$mid'; Title='$member2'; OnMouseOut="window.status=''; return true;"  OnMouseOver="window.status='$member2'; return true;" >\n";
and a link where you will see the error

http://www.theperfectpage.org/bb/index. ... =membermap

It only happens in IE but is fine in Opera

Any help will be much appreciated
lolpix
Forum Commoner
Posts: 41
Joined: Sat Jul 17, 2004 2:20 am

Post by lolpix »

It sounds like it may be an issue with a javascript.
lolpix
Forum Commoner
Posts: 41
Joined: Sat Jul 17, 2004 2:20 am

Post by lolpix »

It might help if you strip single quotes from $member2 before echoing it in $htmlmap's Title attribute or use double quotes inside $htmlmap.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

unterminated strings in javascript are supposed to create an error. You should escape them. Although it probably doesn't both most browsers, there probably shouldn't be semicolons inside the tag text (excluding property values)
jtc970
Forum Commoner
Posts: 38
Joined: Sun Jan 18, 2004 11:49 pm

Post by jtc970 »

the error is on line 343 which is built on this line


$htmlmap .= "<area SHAPE=RECT COORDS='$locx,$locy,$locx2,$locy2'; href='index.php?showuser=$mid'; Title='$member2'; OnMouseOut=\"window.status=''; return true;\" OnMouseOver=\"window.status='$member2'; return true;\" >\n";

I look at the source and cant see any difference between the line with the error and all the other lines above and below it.
if I take the single quote out of my location field the error goes away, but it's odd because the single quote does get converted to ' in the source

:shrug
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

try resetting the variable to a [php_man]urlencode[/php_man]() of said variable before that line..
Last edited by feyd on Fri Jul 23, 2004 3:42 pm, edited 1 time in total.
jtc970
Forum Commoner
Posts: 38
Joined: Sun Jan 18, 2004 11:49 pm

Post by jtc970 »

Thank you all
changing the line to (as lolpix suggested)

Code: Select all

$htmlmap .= "<area SHAPE=RECT COORDS='$locx,$locy,$locx2,$locy2';  href='index.php?showuser=$mid'; Title='$member2'; OnMouseOut="window.status=''; return true;"  OnMouseOver='window.status="$member2"; return true;' >\n";
solved the problem
Post Reply