Page 1 of 1

Error: Expected ;

Posted: Fri Jul 23, 2004 2:59 pm
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

Posted: Fri Jul 23, 2004 3:19 pm
by lolpix
It sounds like it may be an issue with a javascript.

Posted: Fri Jul 23, 2004 3:26 pm
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.

Posted: Fri Jul 23, 2004 3:28 pm
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)

Posted: Fri Jul 23, 2004 3:34 pm
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

Posted: Fri Jul 23, 2004 3:40 pm
by feyd
try resetting the variable to a [php_man]urlencode[/php_man]() of said variable before that line..

Posted: Fri Jul 23, 2004 3:41 pm
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