Displaying points on google maps with data from MySQL database

Hi, I’m trying to use data from my database to plot points on a google map. I’m using php to connect to the database and then echo the code including the relevant long and lat information and also the name and description for each record that matches the city specified.

I am getting the following error:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ‘,’ or ‘;’ in /- on line 174

Here is the section of code that is apparently causing the issue:

<?php while($row = mysql_fetch_array($result)){ echo "var point = new GLatLng(".$row['lat']", ".$row['lng']");"; echo "var marker = createMarker(point, \"".$row['name']"\" , \"


\")" echo "map.addOverlay(marker);"; } ?>

Any help appreciated.

Hi there,

Your first part of concatenation is done properly “string”.$variable but when you go back to the string you are not using the . (you have “string”.$variable"more string" – this should be “string”.$variable.“more string”).

Check where you are using $row[‘lat’], $row[‘name’] etc

Sponsor our Newsletter | Privacy Policy | Terms of Service