Forum Moderators: coopster
I end up with XML that is incomplete and therefore makes the rest of the app no good...
Why would it work sometimes and not others? Why would it stop generating the XML, sometimes in the middle of a word?
Any help?
[CODE]
<!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">
<?
if($_POST['submit'])
{
$dbh=mysql_connect ("localhost", "orlandoi_gmap", "gmap") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("orlandoi_gmap");
$InputtedZIP = ($_POST['InputtedZIP']);
$inputCoords = mysql_query("Select LAT, LNG from coord_db where ZIP = $InputtedZIP") or die(mysql_error());
while($row = mysql_fetch_array($inputCoords))
{
?>
<tr>
<td><font color=#000000 face="arial">Map has been generated showing all ZIP Codes containing a Festiva Owner within a 50 mile radius of the ZIP code <?php echo $InputtedZIP;?></td>
</tr>
<?php
$inputLAT = $row['LAT'];
$inputLATMINUS = $inputLAT - .192;
$inputLATPLUS = $inputLAT + .192;
$inputLNG = $row['LNG'];
$inputLNGPLUS = $inputLNG + .164;
$inputLNGMINUS = $inputLNG - .164;
$availZIP = mysql_query("SELECT ZIP from coord_db WHERE (LAT BETWEEN $inputLATMINUS AND $inputLATPLUS) AND (LNG BETWEEN $inputLNGMINUS AND $inputLNGPLUS)") or die(mysql_error());
$_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
$_xml .="<markers>\r\n";
while ($roo = mysql_fetch_array($availZIP)) {
$ZIPArr = $roo['ZIP'];
$ZIPQuery = mysql_query("SELECT ZIPCode, FirstName, LastName from owner_zips WHERE ZipCode = $ZIPArr") or die (mysql_error());
while ($rop = mysql_fetch_array($ZIPQuery)) {
$ownerrop = $rop['ZIPCode'];
$availCOORD = mysql_query("SELECT LAT,LNG from coord_db WHERE ZIP = $ownerrop") or die(mysql_error());
while ($rou = mysql_fetch_array($availCOORD)) {
if ($rou["LAT"]) {
$_xml .="\t<marker lat=\"" . $rou["LAT"] . "\" lng=\"" . $rou["LNG"] . "\" html=\"" . $rop['FirstName'] . " " . $rop["LastName"] . "\" label=\"" . $rop["ZIPCode"] . "\" />\r\n";
}
}
}
}
$_xml .="</markers>";
$file= fopen("results.xml", "w");
fwrite($file, $_xml);
fclose($file);
echo "<a href=\"gmapnames.php?LATCNT=$inputLAT&LNGCNT=$inputLNG\">View the map!.</a>";
}
}
?>
the script crashes in the middle of generating the XML
What error message are you receiving? Have you turned up error_reporting() [php.net] so you can tell?
The reason I know it's crashing, is that when I use the app and no markers are displayed, I look at the XML that was generated and I see that the file just stops, usually in the middle of a word. The incomplete file causes the error.
What I'm asking is if there's something that's wrong with my script that would cause the xml file generation to stop mid-stream?
$_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";If you have short_open_tag [php.net] on you might be causing yourself some issues.