I have worked my way through the Output mySQL data as XML with PHP tutorial written by Jubba and it is working like a dream with one exception. The first record of the query is getting dropped from the xml data the php page generates and an extrat “empty” record is being generated after the last record. I am using Dreamweaver to create the php page and am using it to make the database connections as well. The query test is returning all of the records but the first record gets dropped when the page is executed on the server. The interesting part is that the page knows how many records have been returned but it fails to write the first one and includes an empty one at the end of the file. I have tried changing the sort order and filter to see if it was specific to a particular column in one of my tables but the results are the same no matter what I do… I am posting my php code along with the resulting XML data.
Here is my php code:
<?php require_once(‘Connections/wcgwebs.php’); ?>
<?php
if (!function_exists(“GetSQLValueString”)) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = “”, $theNotDefinedValue = “”)
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists(“mysql_real_escape_string”) ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case “text”:
$theValue = ($theValue != “”) ? “’” . $theValue . “’” : “NULL”;
break;
case “long”:
case “int”:
$theValue = ($theValue != “”) ? intval($theValue) : “NULL”;
break;
case “double”:
$theValue = ($theValue != “”) ? “’” . doubleval($theValue) . “’” : “NULL”;
break;
case “date”:
$theValue = ($theValue != “”) ? “’” . $theValue . “’” : “NULL”;
break;
case “defined”:
$theValue = ($theValue != “”) ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_wcgwebs, $wcgwebs);
$query_rs_listingphotos = "SELECT listingID, listingURL, listingAgent01ID FROM listing WHERE listingAgent01ID = 123 ORDER BY listingID DESC ";
$rs_listingphotos = mysql_query($query_rs_listingphotos, $wcgwebs) or die(mysql_error());
$row_rs_listingphotos = mysql_fetch_assoc($rs_listingphotos);
$totalRows_rs_listingphotos = mysql_num_rows($rs_listingphotos);
header(“Content-type: text/xml”);
$xml_output = "<?xml version=“1.0” encoding=“utf-8”?>
";
$xml_output .= “<images>
“;
for($x = 0 ; $x < mysql_num_rows($rs_listingphotos) ; $x++){
$row = mysql_fetch_assoc($rs_listingphotos);
$xml_output .= " <pic>
“;
$xml_output .= " <image>” . ‘http://www.wcgdev.com/webimages/thumbnails/’ . $row[‘listingID’] . _photo01_163x109 . ‘.’ . jpg . “</image>
“;
$xml_output .= " <caption>” . ‘http://’ . $row[‘listingURL’] . “</caption>
“;
$xml_output .= " <link>” . ‘http://’ . $row[‘listingURL’] . “</link>
“;
// Escaping illegal characters
$row[‘listingURL’] = str_replace(”&”, “&”, $row[‘listingURL’]);
$row[‘listingURL’] = str_replace(”<”, “<”, $row[‘listingURL’]);
$row[‘listingURL’] = str_replace(”>”, “>”, $row[‘listingURL’]);
$row[‘listingURL’] = str_replace(""", “”", $row[‘listingURL’]);
$xml_output .= " </pic>
";
}
$xml_output .= “</images>”;
echo $xml_output;
Here is the XML data:
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<?xml version=“1.0” encoding=“utf-8” ?>[/COLOR]
[FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]images[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]pic[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]image[/COLOR][COLOR=#0000ff]>[/COLOR]http://www.wcgdev.com/webimages/thumbnails/116_photo01_163x109.jpg[COLOR=#0000ff]</[/COLOR][COLOR=#990000]image[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]caption[/COLOR][COLOR=#0000ff]>[/COLOR]http://www.549canyonmeadows.com[COLOR=#0000ff]</[/COLOR][COLOR=#990000]caption[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]link[/COLOR][COLOR=#0000ff]>[/COLOR]http://www.549canyonmeadows.com[COLOR=#0000ff]</[/COLOR][COLOR=#990000]link[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]</[/COLOR][COLOR=#990000]pic[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]pic[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]image[/COLOR][COLOR=#0000ff]>[/COLOR][COLOR=#0000ff]</[/COLOR][COLOR=#990000]image[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]caption[/COLOR][COLOR=#0000ff]>[/COLOR]http://www.3543hunterscircle.com[COLOR=#0000ff]</[/COLOR][COLOR=#990000]caption[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]link[/COLOR][COLOR=#0000ff]>[/COLOR]http://www.3543hunterscircle.com[COLOR=#0000ff]</[/COLOR][COLOR=#990000]link[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]</[/COLOR][COLOR=#990000]pic[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]pic[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]image[/COLOR][COLOR=#0000ff]>[/COLOR][COLOR=#0000ff]</[/COLOR][COLOR=#990000]image[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]caption[/COLOR][COLOR=#0000ff]>[/COLOR]http://www.1562parkwood.com[COLOR=#0000ff]</[/COLOR][COLOR=#990000]caption[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]link[/COLOR][COLOR=#0000ff]>[/COLOR]http://www.1562parkwood.com[COLOR=#0000ff]</[/COLOR][COLOR=#990000]link[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]</[/COLOR][COLOR=#990000]pic[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]pic[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]image[/COLOR][COLOR=#0000ff]>[/COLOR]http://www.wcgdev.com/webimages/thumbnails/57_photo01_163x109.jpg[COLOR=#0000ff]</[/COLOR][COLOR=#990000]image[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]caption[/COLOR][COLOR=#0000ff]>[/COLOR]http://www.194cazneau.com[COLOR=#0000ff]</[/COLOR][COLOR=#990000]caption[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]link[/COLOR][COLOR=#0000ff]>[/COLOR]http://www.194cazneau.com[COLOR=#0000ff]</[/COLOR][COLOR=#990000]link[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]</[/COLOR][COLOR=#990000]pic[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]pic[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]image[/COLOR][COLOR=#0000ff]>[/COLOR]http://www.wcgdev.com/webimages/thumbnails/56_photo01_163x109.jpg[COLOR=#0000ff]</[/COLOR][COLOR=#990000]image[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]caption[/COLOR][COLOR=#0000ff]>[/COLOR]http://www.1821parkave.com[COLOR=#0000ff]</[/COLOR][COLOR=#990000]caption[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]link[/COLOR][COLOR=#0000ff]>[/COLOR]http://www.1821parkave.com[COLOR=#0000ff]</[/COLOR][COLOR=#990000]link[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]</[/COLOR][COLOR=#990000]pic[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]pic[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]image[/COLOR][COLOR=#0000ff]>[/COLOR]http://www.wcgdev.com/webimages/thumbnails/48_photo01_163x109.jpg[COLOR=#0000ff]</[/COLOR][COLOR=#990000]image[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]caption[/COLOR][COLOR=#0000ff]>[/COLOR]http://www.1219lantanacourt.com[COLOR=#0000ff]</[/COLOR][COLOR=#990000]caption[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]link[/COLOR][COLOR=#0000ff]>[/COLOR]http://www.1219lantanacourt.com[COLOR=#0000ff]</[/COLOR][COLOR=#990000]link[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]</[/COLOR][COLOR=#990000]pic[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]pic[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]image[/COLOR][COLOR=#0000ff]>[/COLOR][COLOR=#0000ff]</[/COLOR][COLOR=#990000]image[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]caption[/COLOR][COLOR=#0000ff]>[/COLOR]http://www.105mccormickct.com[COLOR=#0000ff]</[/COLOR][COLOR=#990000]caption[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]link[/COLOR][COLOR=#0000ff]>[/COLOR]http://www.105mccormickct.com[COLOR=#0000ff]</[/COLOR][COLOR=#990000]link[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]</[/COLOR][COLOR=#990000]pic[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]pic[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]image[/COLOR][COLOR=#0000ff]>[/COLOR]http://www.wcgdev.com/webimages/thumbnails/_photo01_163x109.jpg[COLOR=#0000ff]</[/COLOR][COLOR=#990000]image[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]caption[/COLOR][COLOR=#0000ff]>[/COLOR]http://[COLOR=#0000ff]</[/COLOR][COLOR=#990000]caption[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]link[/COLOR][COLOR=#0000ff]>[/COLOR]http://[COLOR=#0000ff]</[/COLOR][COLOR=#990000]link[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]</[/COLOR][COLOR=#990000]pic[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]</[/COLOR][COLOR=#990000]images[/COLOR][COLOR=#0000ff]>[/COLOR]
[COLOR=#0000ff][/COLOR]
[COLOR=#0000ff]I am stumped!! :h: Any and ALL help would be be greatly appreciated!![/COLOR]
[COLOR=#0000ff][/COLOR]
[COLOR=#0000ff]sodaril[/COLOR]