phpgurl Posted August 24, 2007 Share Posted August 24, 2007 I'm trying to learn to use both php and the google maps api. I made a file that works without using php, but now I'm hoping to do the same connecting to a database. I'm getting this error: Parse error: syntax error, unexpected $end in /home/site_user_name/public_html/exercises/geocoder2.php on line 79 Line 79 is at the end of my file. It's blank. Here is the code i'm using: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <?php $connection = mysql_connect("localhost", "user", "pw"); if (!$connection){ die("Could not connect to the database: <br/>" . mysql_error()); } $db_select = mysql_select_db("database"); if (!$db_select) { die ("could not select the database: <br />". mysql_error()); } $query = "SELECT * FROM location"; $result = mysql_query( $query ); if (!$result){ die ("Could not query the database: <br />". mysql_error()); } while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $street=$row["street"]; $city=$row["city"]; $stateabbr=$row["stateabbr"]; $zipcode=$row["zipcode"]; ?> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title>Google Maps API Example - Geocoding API</title> <script src="http://maps.google.com/maps?file=api&v=2.x&key=xxxxxx" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ var map = null; var geocoder = null; function load() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map")); map.setCenter(new GLatLng(37.4419, -122.1419), 13); geocoder = new GClientGeocoder(); <?php echo "showAddress('$street, $city, $stateabbr $zipcode');"; ?> } } function showAddress(address) { if (geocoder) { geocoder.getLatLng( address, function(point) { if (!point) { alert(address + " not found"); } else { map.setCenter(point, 13); var marker = new GMarker(point); map.addOverlay(marker); marker.openInfoWindowHtml(address); } } ); } } //]]> </script> </head> <body onload="load()" onunload="GUnload()"> <div id="map" style="width: 500px; height: 300px"></div> <?php mysql_close($connection); ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/66451-solved-error-need-help-debugging/ Share on other sites More sharing options...
phpgurl Posted August 24, 2007 Author Share Posted August 24, 2007 I'm happy to say I found the issue - surfing around for the error - I learned I had one too few curly brace }. Quote Link to comment https://forums.phpfreaks.com/topic/66451-solved-error-need-help-debugging/#findComment-332767 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.