Google markers display in chrome not ie and firefox

i am pulling data from a mysql database and i used the example on google maps for displaying map makers on a map, i have made code changes to the the org file, and its working really well in chrome, i had a friend try in firefox and it is blank no markers at all, i have fixed the errors that firebug gave. and i have ran the page with wc3 it has an error of

Validation Output: 1 Error

Error Line 9, Column 69: & did not start a character reference. (& probably should have been escaped as &.)
…script src="http://maps.google.com/maps/api/js?libraries=geometry&sensor=false"
note: above wc3 error is on line 8 in below code

any help on why im not getting markers please
thank you in advance for any code or help you may provide.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
		<title>Google Maps AJAX + mySQL/PHP Example</title>
		<script src="http://maps.google.com/maps/api/js?libraries=geometry&sensor=false"
		type="text/javascript"></script>
		<script type="text/javascript">
			//<![CDATA[


var customIcons = {
restaurant: {
icon: 'http://labs.google.com/ridefinder/images/mm_20_blue.png',
shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
},
bar: {
icon: 'http://labs.google.com/ridefinder/images/mm_20_red.png',
shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
}
};

function load() {
var map = new google.maps.Map(document.getElementById("map"), {
center: new google.maps.LatLng(39.924226999999995,-83.80881699999999), zoom:10	, mapTypeId: 'roadmap'
	});

google.maps.event.addListener(map, 'click', find_closest_marker);


	var infoWindow = new google.maps.InfoWindow;

	// Change this depending on the name of your PHP file
	downloadUrl("phpsqlajax_genxml.php", function(data) {
		var xml = data.responseXML;
		var markers = xml.documentElement.getElementsByTagName("marker");
		for (var i = 0; i < markers.length; i++) {
			var name = markers[i].getAttribute("name");
			var address = markers[i].getAttribute("address");
			var type = markers[i].getAttribute("type");
			var id = markers[i].getAttribute("id");
			var loc = markers[i].getAttribute("loc");
			var img = markers[i].getAttribute("img");
			var cat = markers[i].getAttribute("cat");
			var point = new google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng")));
			//var html = "<A HREF='../single_event_page.php?id=" + id + "' target='_parent' title='" + loc + ">" + name + "</a> <br/>" + address;
			var html ='<div id="content" style="margin-left:15px; margin-top:3px;overflow:hidden;">'+
                           '<div id="bodyContent">'+
                            '<img src="'+
                            img+
                            '" style="width:45px;height:45px;" align="left" alt="event image"/>' +
                            '<br> <br><br><font style="color:darkblue;font:11px tahoma;margin-left:5px;"> <A HREF="../single_event_page.php?id=' +
                            id + '" target="_parent" title="' +
                            loc + '"> '+
                            name +
                            '</a></font>'+
                            '<br><div style="font:13px verdana;color:darkgreen; margin-left:5px;">' +
                            '<br>'+
                            cat+'<br>'+
                           '</div>'+
                           '</div>';

			var icon = customIcons[type] || {};
			var marker = new google.maps.Marker({
				map : map,
				position : point,
				icon : icon.icon,
				shadow : icon.shadow
			});
			bindInfoWindow(marker, map, infoWindow, html);
		}
	});
	}



	function bindInfoWindow(marker, map, infoWindow, html) {
		google.maps.event.addListener(marker, 'click', function() {
			infoWindow.setContent(html);
			infoWindow.open(map, marker);
		});
	}

	function downloadUrl(url, callback) {
		var request = window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest;

		request.onreadystatechange = function() {
			if (request.readyState == 4) {
				request.onreadystatechange = doNothing;
				callback(request, request.status);
			}
		};

		request.open('GET', url, true);
		request.send(null);
	}

	function doNothing() {
	}

function rad(x) {return x*Math.PI/180;}
function find_closest_marker( event ) {
    var lat = event.latLng.lat();
    var lng = event.latLng.lng();
    var R = 6371; // radius of earth in km
    var distances = [];
    var closest = -1;
    for( i=0;i<map.markers.length; i++ ) {
        var mlat = map.markers[i].position.lat();
        var mlng = map.markers[i].position.lng();
        var dLat  = rad(mlat - lat);
        var dLong = rad(mlng - lng);
        var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
            Math.cos(rad(lat)) * Math.cos(rad(lat)) * Math.sin(dLong/2) * Math.sin(dLong/2);
        var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
        var d = R * c;
        distances[i] = d;
        if ( closest == -1 || d < distances[closest] ) {
            closest = i;
        }
    }

    alert(map.markers[closest].title);
}



	//]]>
		</script>
	</head>

	<body onload="load()">
		<div id="map" style="width: 100%; height: 500px"></div>
	</body>
</html>

Open in new window


sample xml
<?xml version="1.0" encoding="utf-8"?>
<markers><marker name="Metal Machine Monday- Upstairs at EXIT" loc="Location: Exit
1315 W North Ave
Chicago, IL, 60642-1513" id="1" address="Exit
1315 W North Ave
Chicago, IL, 60642-1513" lat="41.910461" lng="-87.660980" img="https://fbcdn-sphotos-g-a.akamaihd.net/hphotos-ak-prn1/c268.0.315.315/s552x414/560827_10151619336171173_851548175_n.jpg" cat="Bar" /><marker name="50 cent Boneless Wings" loc="Location: Wing Stop
3326 North Western Avenue
Riverview Plaza, Chicago, IL 60618" id="2" address="Wing Stop
3326 North Western Avenue
Riverview Plaza, Chicago, IL 60618" lat="41.940685" lng="-87.696442" img="http://chicagoil.iswhereitsat.com/wp-content/themes-ai1ec/vortex/img/default-event-avatar.png" cat="Restaurant" /><marker name="Lincoln Park Zoo?s Edible Garden" loc="Location: Farm In The Zoo
2001 North Clark Street
Chicago, IL 60614" id="3" address="Farm In The Zoo
2001 North Clark Street
Chicago, IL 60614" lat="0.000000" lng="0.000000" img="http://chicagoil.iswhereitsat.com/wp-content/uploads/sites/10/2013/06/edible-garden2.jpg" cat="" /><marker name="Happy Hour at Frankie?s 5th Floor Pizzeria" loc="Location: Frankie's 5th Floor Pizzeria
900 North Michigan
Chicago, IL 60611" id="4" address="Frankie&amp;#39;s 5th Floor Pizzeria
900 North Michigan
Chicago, IL 60611" lat="41.892509" lng="-87.616173" img="http://chicagoil.iswhereitsat.com/wp-content/themes-ai1ec/vortex/img/default-event-avatar.png" cat="Restaurant" /><marker name="Socrates Party" loc="Location: 709 S Randolph St Champaign, IL 61820" id="5" address="709 S Randolph St Champaign, IL 61820" lat="0.000000" lng="0.000000" img="http://chicagoil.iswhereitsat.com/wp-content/themes-ai1ec/vortex/img/default-event-avatar.png" cat="" /><marker name="Test should show up as boston only" loc="Location: 131 main st Boston, Ma" id="6" address="131 main st Boston, Ma" lat="0.000000" lng="0.000000" img="http://chicagoil.iswhereitsat.com/wp-content/themes-ai1ec/vortex/img/default-event-avatar.png" cat="" /><marker name="Chicago Toy and Game Fair" loc="Location: Navy Pier, Inc 600 E Grand Ave, Chicago, IL 60611" id="271" address="Navy Pier, Inc 600 E Grand Ave, Chicago, IL 60611" lat="41.891739" lng="-87.599876" img="http://blog.navypier.com/wp-content/uploads/headway/header-uploads/navy-blog2_08.png" cat="point_of_interest, amusement_p" /><marker name="Chicago Chocolate Festival" loc="Location: Navy Pier, Inc 600 E Grand Ave, Chicago, IL 60611" id="272" address="Navy Pier, Inc 600 E Grand Ave, Chicago, IL 60611" lat="41.891739" lng="-87.599876" img="http://blog.navypier.com/wp-content/uploads/headway/header-uploads/navy-blog2_08.png" cat="point_of_interest, amusement_p" /></markers>

Open in new window

JohnnyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
Please give us a link to the page.  It is much easier and more accurate to use the developer tool built-in to the browsers to figure these things out.
0
RobOwner (Aidellio)Commented:
As @DaveBaldwin has said, please post the link for us to look at.  There will probably be errors in the console (press F12 for dev tools and go to console).  If there are then post them here.
0
RobOwner (Aidellio)Commented:
You are missing ( ) in your ajax function (line 87):

var request = window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest;

Open in new window


the XMLHttpRequest requires the ()

ie

var request = window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();

Open in new window

0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

leakim971PluritechnicianCommented:
work fine for me :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
		<title>Google Maps AJAX + mySQL/PHP Example</title>
		<script src="http://maps.google.com/maps/api/js?libraries=geometry&sensor=false"
		type="text/javascript"></script>
		<script type="text/javascript">
			//<![CDATA[

			var customIcons = {
				restaurant: {
					icon : 'http://labs.google.com/ridefinder/images/mm_20_blue.png',
					shadow : 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
				},
				bar: {
					icon : 'http://labs.google.com/ridefinder/images/mm_20_red.png',
					shadow : 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
				}
			};

			function load() {
				var map = new google.maps.Map(document.getElementById("map"), {
					center : new google.maps.LatLng(39.924226999999995,-83.80881699999999),
					zoom : 10,
					mapTypeId : 'roadmap'
				});

				google.maps.event.addListener(map, 'click', find_closest_marker);

				var infoWindow = new google.maps.InfoWindow;

				// Change this depending on the name of your PHP file
				downloadUrl(
						"phpsqlajax_genxml.php",
						function(data) {
							var xml = data.responseXML;
							var markers = xml.documentElement.getElementsByTagName("marker");
							for ( var i = 0; i < markers.length; i++) {
								var name = markers[i].getAttribute("name");
								var address = markers[i].getAttribute("address");
								var type = markers[i].getAttribute("type");
								var id = markers[i].getAttribute("id");
								var loc = markers[i].getAttribute("loc");
								var img = markers[i].getAttribute("img");
								var cat = markers[i].getAttribute("cat");
								var point = new google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng")));
								//var html = "<A HREF='../single_event_page.php?id=" + id + "' target='_parent' title='" + loc + ">" + name + "</a> <br/>" + address;
								var html = '<div id="content" style="margin-left:15px; margin-top:3px;overflow:hidden;">'
										+ '<div id="bodyContent">'
										+ '<img src="'+img+'" style="width:45px;height:45px;" align="left" alt="event image"/>'
										+ '<br> <br><br><font style="color:darkblue;font:11px tahoma;margin-left:5px;"> <A HREF="../single_event_page.php?id='+id+'" target="_parent" title="'+loc+'"> '+name+'</a></font>'
										+ '<br><div style="font:13px verdana;color:darkgreen; margin-left:5px;">'+'<br>'+cat+'<br>'+'</div>'
										+ '</div>';

								var icon = customIcons[type] || {};
								var marker = new google.maps.Marker({map : map, position : point,icon : icon.icon,shadow : icon.shadow});
								bindInfoWindow(marker, map, infoWindow, html);
							}
						});
			}

			function bindInfoWindow(marker, map, infoWindow, html) {
				google.maps.event.addListener(marker, 'click', function() {
					infoWindow.setContent(html);
					infoWindow.open(map, marker);
				});
			}

			function downloadUrl(url, callback) {
				var request = window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest;

				request.onreadystatechange = function() {
					if (request.readyState == 4) {
						request.onreadystatechange = doNothing;
						callback(request, request.status);
					}
				};

				request.open('GET', url, true);
				request.send(null);
			}

			function doNothing() {
			}

			function rad(x) {
				return x * Math.PI / 180;
			}

			function find_closest_marker(event) {
				var lat = event.latLng.lat();
				var lng = event.latLng.lng();
				var R = 6371; // radius of earth in km
				var distances = [];
				var closest = -1;
				for (i = 0; i < map.markers.length; i++) {
					var mlat = map.markers[i].position.lat();
					var mlng = map.markers[i].position.lng();
					var dLat = rad(mlat - lat);
					var dLong = rad(mlng - lng);
					var a = Math.sin(dLat / 2) * Math.sin(dLat / 2)+ Math.cos(rad(lat)) * Math.cos(rad(lat)) * Math.sin(dLong / 2) * Math.sin(dLong / 2);
					var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
					var d = R * c;
					distances[i] = d;
					if (closest == -1 || d < distances[closest]) {
						closest = i;
					}
				}

				alert(map.markers[closest].title);
			}

			//]]>
		</script>
	</head>
	<body onload="load()">
		<div id="map" style="width: 100%; height: 500px"></div>
	</body>
</html>

Open in new window

0
Julian HansenCommented:
Ran your code locally

markers are there - you need to zoom out to see them they seem to be grouped to the north.
0
RobOwner (Aidellio)Commented:
The experts are right... as @julianH said the markers are grouped slightly NWN on Chicago

you can test it yourself here: http://jsbin.com/ehusiGa/2/embed?live,html
works on firefox too
0
leakim971PluritechnicianCommented:
I don't think the question is about where's the makers

Google markers display in chrome not ie and firefox
0
Julian HansenCommented:
I don't think the question is about where's the makers

The question is about markers not showing - if the markers are off screen then they won't show - presents exactly as if no markers.

The test was done in firefox and chrome - same result.

So, either we are dealing with code different what was posted
Or the code works and the markers are there just off screen (which would explain the problem)
If #2 then it might be that the feedback to the author from the FF / Chrome testers might have ommitted the bit about zooming out to find the markers.

As things stand I go with my earlier post - the markers are there but off screen.
0
RobOwner (Aidellio)Commented:
See my last post "works on firefox too"

The jsbin fails in IE due to security issues and iframe access apparent violation
SEC7131: Security of a sandboxed iframe is potentially compromised by allowing script and same origin access.
0
JohnnyAuthor Commented:
well thank you for all the replies
if you read the post i did check firebug for the console and i fixed the errors it had.

the problem is the markers do not show up at all (yes most are north east chicago area for testing) they show up fine in Google Chrome Browser, and have been all a long(save a broken javascript routine, and that's normal) but ie and firefox browsers not at all. this is the problem and the question hot to get them to show up in FF and IE.

i changed or rather added the () to the xml..request and still no joy on my page. did i miss something else thats missing?

heres the page on my server, there are other markers on the page as they are in the database.
testing example

with the exception if the xml data the codes the same as posted
0
leakim971PluritechnicianCommented:
DaveBaldwin asked:
Please give us a link to the page.  It is much easier and more accurate to use the developer tool built-in to the browsers to figure these things out.

And did you tried my code?
0
Julian HansenCommented:
this is the problem and the question hot to get them to show up in FF and IE.
Except several experts have posted back here saying that the markers do show up in FF ...

So unless you can give us an example of code that does not work in FF - not much we can do to help.

I just cut and pasted your code from the sample site and the XML from the code that is generated into local scripts and they work fine.

The only difference is that I am using my own phpsqlajax_genxml.php - as you did not post yours and in that file the first line of output is

<?php header('Content-type: application/xml');?>


(see attached for full source)

So maybe that is where your problem is - send the correct MIME header first.
phpsqlajax-genxml.php
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JohnnyAuthor Commented:
running the xml page directly has an error.
http://completelocal.info/ee_testing/phpsqlajax_genxml.php
there's a buncha - or something, ff and chrome see it differently, im not sure where the problem is.

my code to generate the xml taking out the ? from print '<?xml version="1.0" encoding="utf-8"?>'."\n"; breaks the xml for google chrome
<?php
require("phpsqlajax_dbinfo.php");

function parseToXML($htmlStr) 
{ 
$xmlStr=str_replace('<','&lt;',$htmlStr); 
$xmlStr=str_replace('>','&gt;',$xmlStr); 
$xmlStr=str_replace('"','&quot;',$xmlStr); 
$xmlStr=str_replace("'",'&#39;',$xmlStr); 
$xmlStr=str_replace("&",'&amp;',$xmlStr); 
return $xmlStr; 
} 

// Opens a connection to a MySQL server
$connection=mysql_connect (localhost, $username, $password);
if (!$connection) {
  die('Not connected : ' . mysql_error());
}

// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
  die ('Can\'t use db : ' . mysql_error());
}

// Select all the rows in the markers table
$query = "SELECT * FROM iwia_events WHERE 1";
$result = mysql_query($query);
if (!$result) {
  die('Invalid query: ' . mysql_error());
}

header('Content-Type: text/xml; charset=utf-8;');
print '<?xml version="1.0" encoding="utf-8"?>'."\n";

// Start XML file, echo parent node
echo '<markers>';

// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
  // ADD TO XML DOCUMENT NODE
      echo '<marker ';
  //echo 'name="'.$title.'"';
  echo 'name="'.utf8_decode (parseToXML($row['event_title'])) . '" ';
  if ($row['event_location']) {
      $loc = "Location: ".$row['event_location']."";
      echo 'loc="' . $loc . '" ';
  } 
  echo 'id="' . $row['id'] . '" ';
  echo 'address="' . parseToXML($row['event_location']) . '" ';
  echo 'lat="' . $row['lat'] . '" ';
  echo 'lng="' . $row['lng'] . '" ';
  echo 'img="' . $row['event_image'] . '" ';
  echo 'cat="' . $row['type'] . '" ';
  echo '/>';
}

// End XML file
echo '</markers>';

?>

Open in new window

0
JohnnyAuthor Commented:
@leakim971 whats different from your code? i tried it see example here
i do not think it was the code anymore save the missing ().
i think its the xml generation as we are getting errors there.
but to note your code doesn't work in Firefox either. (in the example i posted from yours)
so again i belive its the xml generation and not the main code.

again thank you everyone for the help so far
0
leakim971PluritechnicianCommented:
your XML file is malformed because you're not encoding special characters :
"<parsererror xmlns="http://www.mozilla.org/newlayout/xml/parsererror.xml">

Open in new window


You have a good example on this page :
https://developers.google.com/maps/articles/phpsqlajax_v3?hl=de#outputxml
0
JohnnyAuthor Commented:
@ leakim971 thats the code im using. exact page i used as an example

function parseToXML($htmlStr) 
{ 
$xmlStr=str_replace('<','&lt;',$htmlStr); 
$xmlStr=str_replace('>','&gt;',$xmlStr); 
$xmlStr=str_replace('"','&quot;',$xmlStr); 
$xmlStr=str_replace("'",'&#39;',$xmlStr); 
$xmlStr=str_replace("&",'&amp;',$xmlStr); 
return $xmlStr; 
} 

Open in new window


code from that page "Using PHP's echo to Output XML" section only think i did different is that i added " print '<?xml version="1.0" encoding="utf-8"?>'."\n";"
0
leakim971PluritechnicianCommented:
0
JohnnyAuthor Commented:
is there a way for that output to have line breaks its all jumbled up.
and now with htmlentities i get
This page contains the following errors:

error on line 18 at column 1689: Entity 'rsquo' not defined
Below is a rendering of the page up to the first error.
0
JohnnyAuthor Commented:
.PHP_EOL makes line breaks
0
JohnnyAuthor Commented:
current code working i'm working with
<?php
require("phpsqlajax_dbinfo.php");

function parseToXML($htmlStr) 
{ 
$xmlStr=str_replace('<','&lt;',$htmlStr); 
$xmlStr=str_replace('>','&gt;',$xmlStr); 
$xmlStr=str_replace('"','&quot;',$xmlStr); 
$xmlStr=str_replace("'",'&#39;',$xmlStr); 
$xmlStr=str_replace("&",'&amp;',$xmlStr); 
return $xmlStr; 
} 

// Opens a connection to a MySQL server
$connection=mysql_connect (localhost, $username, $password);
if (!$connection) {
  die('Not connected : ' . mysql_error());
}

// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
  die ('Can\'t use db : ' . mysql_error());
}

// Select all the rows in the markers table
$query = "SELECT * FROM iwia_events WHERE 1";
$result = mysql_query($query);
if (!$result) {
  die('Invalid query: ' . mysql_error());
}

header('Content-Type: text/xml; charset=utf-8;');
print '<?xml version="1.0" encoding="utf-8"?>'."\n";

// Start XML file, echo parent node
echo '<markers>'.PHP_EOL;

// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
  // ADD TO XML DOCUMENT NODE
      echo '<marker '.PHP_EOL;
  //echo 'name="'.$title.'"';
  echo 'name="'.utf8_decode (htmlentities($row['event_title'])) . '" '.PHP_EOL;
  if ($row['event_location']) {
      $loc = "Location: ".$row['event_location']."";
      echo 'loc="' . htmlentities($loc) . '" '.PHP_EOL;
  } 
  echo 'id="' . $row['id'] . '" '.PHP_EOL;
  echo 'address="' . htmlentities($row['event_location']) . '" '.PHP_EOL;
  echo 'lat="' . $row['lat'] . '" '.PHP_EOL;
  echo 'lng="' . $row['lng'] . '" '.PHP_EOL;
  echo 'img="' . $row['event_image'] . '" '.PHP_EOL;
  echo 'cat="' . $row['type'] . '" '.PHP_EOL;
  echo "/>".PHP_EOL;
}

// End XML file
echo '</markers>';

?>

Open in new window

0
JohnnyAuthor Commented:
i changed it back to the parse_to_xml to see if i can find the error
getting an error of
This page contains the following errors:

error on line 819 at column 1: Encoding error
Below is a rendering of the page up to the first error.

Open in new window


<marker 
name="Fireworks Cruise aboard Seadog" 
loc="Location: Navy Pier, Inc 600 E Grand Ave, Chicago, IL 60611" 
id="136" 
address="Navy Pier, Inc 600 E Grand Ave, Chicago, IL 60611" 
lat="41.891739" 
lng="-87.599876" 
img="http://blog.navypier.com/wp-content/uploads/headway/header-uploads/navy-blog2_08.png" 
cat="point_of_interest, amusement_p" 
/>
<marker 
name="Shoreline Sightseeing July 4th , Inc 600 E Grand Ave, Chicago, IL 60611" 
id="151" 
address="Navy Pier, Inc 600 E Grand Ave, Chicago, IL 60611" 
lat="41.891739" 
lng="-87.599876" 
img="http://blog.navypier.com/wp-content/uploads/headway/header-uploads/navy-blog2_08.png" 
cat="point_of_interest, amusement_p" 
/>

Open in new window

it says the error is at line 11 <marker

HUH what i think the browsers are nuts unless im seriously missing something here
0
leakim971PluritechnicianCommented:
Hidden chars :hidden char
0
JohnnyAuthor Commented:
ok so how do i get rid of the Hidden chars? and how the heck did u find them too.
0
JohnnyAuthor Commented:
current code im working with now
and @ leakim971 it was htmlspecialchars not htmlentities you mentioned before (i get them confused too sometimes on what they each do)
<?php
require("phpsqlajax_dbinfo.php");

function htmlspecialchars2($htmlStr) 
{ 
$xmlStr=str_replace('<','&lt;',$htmlStr); 
$xmlStr=str_replace('>','&gt;',$xmlStr); 
$xmlStr=str_replace('"','&quot;',$xmlStr); 
$xmlStr=str_replace("'",'&#39;',$xmlStr); 
$xmlStr=str_replace("&",'&amp;',$xmlStr); 
return $xmlStr; 
} 

// Opens a connection to a MySQL server
$connection=mysql_connect (localhost, $username, $password);
if (!$connection) {
  die('Not connected : ' . mysql_error());
}

// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
  die ('Can\'t use db : ' . mysql_error());
}

// Select all the rows in the markers table
$query = "SELECT * FROM iwia_events WHERE 1";
$result = mysql_query($query);
if (!$result) {
  die('Invalid query: ' . mysql_error());
}

header('Content-Type: text/xml; charset=utf-8;');
print '<?xml version="1.0" encoding="utf-8"?>'."\n";

// Start XML file, echo parent node
echo '<markers>'.PHP_EOL;

// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
  // ADD TO XML DOCUMENT NODE
      echo '<marker ';
  //echo 'name="'.$title.'"';
  echo 'name="'.utf8_decode (htmlspecialchars($row['event_title'])) . '" ';
  if ($row['event_location']) {
      $row['event_location'] = str_replace(array("\n", "\r"), '', $row['event_location']);  // echo $row['event_location'] in a single line
      $loc = "Location: ".$row['event_location']."";
      echo 'loc="' . htmlspecialchars($loc) . '" ';
  } 
  echo 'id="' . $row['id'] . '" ';
  echo 'address="' . htmlspecialchars($row['event_location']) . '" ';
  echo 'lat="' . $row['lat'] . '" ';
  echo 'lng="' . $row['lng'] . '" ';
  echo 'img="' . $row['event_image'] . '" ';
  echo 'cat="' . $row['type'] . '" ';
  echo "/>".PHP_EOL;
}

// End XML file
echo '</markers>';

?>

Open in new window

0
leakim971PluritechnicianCommented:
instead using multiple echo, put all the xml in a string and echo this string at the end, out of the loop
0
leakim971PluritechnicianCommented:
here the line 819-820
just before 60-minute we've this strange char :
strange char
You can remove it using : http://php.net/manual/fr/function.iconv.php
iconv('UTF-8', 'UTF-8//IGNORE', $row['event_title']);

utf8_decode (htmlspecialchars(iconv('UTF-8', 'UTF-8//IGNORE', $row['event_title'])))
0
JohnnyAuthor Commented:
wow now the other data not the ical data is messed up omg i do anything to it today it breaks
grrr
0
JohnnyAuthor Commented:
i went a different way and edited the ical import to parse utf-8 more that seamed to fix some of it.

i apparently have more errors then i thought as i took out the ical import data now with new code it breaks again
0
leakim971PluritechnicianCommented:
I get the markers now on FF and IE
0
JohnnyAuthor Commented:
no the question at hand is how to accept the proper answer

technical
Post by: julianH Posted on 2013-09-12 at 10:14:13ID: 39487307

is what triggered the look in the xml file dummy.

then  leakim971 stuck with it and helped solve it with all the little suggestions.
ill give it 10 mins here, and ill accept  julianH as the answer with 100 points and il give 400 to leakim971 on some post yet to be determined

that sound fair

ps: i still need help with more if this as i seamed to of not only broken another area but the closest marker is no longer working (or did it ever not sure but i need that fixed too)
and i need to figure out why im not getting name now as event info that broke too. grrr more problems but ill post new questions for all that so please be on the look out for them
0
JohnnyAuthor Commented:
@leakim971 yes it works in ff and ie now..it was the utf-8 encoding mucking it all up
0
JohnnyAuthor Commented:
i got it all to work now..
it was mucking up on apos
also note i redid the injections for the ical import to better parse utf-8 as ical seams to like that format and browsers do not.
current code
<?php
require("phpsqlajax_dbinfo.php");

function htmlspecialchars2($htmlStr) 
{ 
$xmlStr=str_replace('<','&lt;',$htmlStr); 
$xmlStr=str_replace('>','&gt;',$xmlStr); 
$xmlStr=str_replace('"','&quot;',$xmlStr); 
$xmlStr=str_replace("'",'&#39;',$xmlStr); 
$xmlStr=str_replace("&",'&amp;',$xmlStr);
$xmlStr=str_replace("’",'&apos;',$xmlStr); 
return $xmlStr; 
} 

// Opens a connection to a MySQL server
$connection=mysql_connect (localhost, $username, $password);
if (!$connection) {
  die('Not connected : ' . mysql_error());
}

// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
  die ('Can\'t use db : ' . mysql_error());
}

// Select all the rows in the markers table
$query = "SELECT * FROM iwia_events WHERE 1";
$result = mysql_query($query);
if (!$result) {
  die('Invalid query: ' . mysql_error());
}

header('Content-Type: text/xml; charset=utf-8;');
print '<?xml version="1.0" encoding="utf-8"?>'."\n";

// Start XML file, echo parent node
echo '<markers>'.PHP_EOL;

// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
  // ADD TO XML DOCUMENT NODE
      echo '<marker ';
  $title=htmlspecialchars2($row['event_title']);
  //$title = addslashes($row['event_title']);
  echo 'name="'.$title.'" ';
  //echo 'name="'.htmlspecialchars($row['event_title']) . '" ';
  if ($row['event_location']) {
      $row['event_location'] = str_replace(array("\n", "\r"), ' ', $row['event_location']);  // echo $row['event_location'] in a single line
      $loc = "Location: ".$row['event_location']."";
      echo 'loc="' . htmlspecialchars($loc) . '" ';
  } 
  echo 'id="' . $row['id'] . '" ';
  echo 'address="' . htmlspecialchars($row['event_location']) . '" ';
  echo 'lat="' . $row['lat'] . '" ';
  echo 'lng="' . $row['lng'] . '" ';
  echo 'img="' . $row['event_image'] . '" ';
  echo 'cat="' . $row['type'] . '" ';
  echo "/>".PHP_EOL;
}

// End XML file
echo '</markers>';

?>

Open in new window

0
Dave BaldwinFixer of ProblemsCommented:
I didn't try any of the code above.  But I did use the code from https://developers.google.com/maps/articles/phpsqlsearch_v3 to implement a store locator with Google maps on a client site.  One of the features in that code (which works in all browsers) is a 'zoom' function that zooms to the area where the markers are located.
0
JohnnyAuthor Commented:
@DaveBaldwin that is what i was looking for now to adapt it to my database and what i'm trying to do..thats prefect tho thanks.
0
JohnnyAuthor Commented:
Thank you all for the help on this post i'm most grateful.
0
Julian HansenCommented:
@Pern - it is a bit confusing when you assign the higher points to the assisted solution. The solution to the problem was the non-UTF-8 characters in the XML file - so that should have been the accepted solution.

As this question stands - for future readers they will read the accpeted solution as the one that solved the problem - which is misleading because the accepted solution points out that there is no problem.

leakim's post should be the accepted and all others assisted.
0
JohnnyAuthor Commented:
@julianH you noticed it was a problem in the gen xml file and the content type, i looked at it closer and i saw the problem basically at the same time that leakim did so you got the accepted answer and he got more points for helping me what ultimately we all together without little pieces derived at the solution.

it was with you the ball got rolling.

Thank you both for all the help
0
Julian HansenCommented:
@Pern - ok but this is not about points it is about how EE is used by other people looking for solutions. All I am saying is that in this case the points split is fine but I would have given leakim's answer the accepted one as it more directly identified the problem. My post did not expressly point out the issue.

Anyway will leave it at that - thanks for the points.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.