# XML not outputing properly from PHP - please look

**URL:** <https://forum.kirupa.com/t/xml-not-outputing-properly-from-php-please-look/280657>\
**Category:** programming\
**Created:** [January 30, 2009, 12:17am UTC](https://forum.kirupa.com/t/xml-not-outputing-properly-from-php-please-look/280657 "2009-01-30T00:17:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![monsterchild](https://avatars.discourse-cdn.com/v4/letter/m/7ea924/32.png) [@monsterchild](https://forum.kirupa.com/u/monsterchild)\
**Post date:** [January 30, 2009, 12:17am UTC](https://forum.kirupa.com/t/xml-not-outputing-properly-from-php-please-look/280657/1 "2009-01-30T00:17:21Z")

</div>

hi all, can someone please look at this code and tell me why i’m getting an error at the for loop?

all i want to do is list the names of people between A and M in and XML document, i’ve been able to use this statement

```php
$select = "SELECT * FROM list ORDER BY last";

```

and it’s listed exactly how i want it but now i just need specific names not the whole DB.

code i’m working with below

```php
$select = "SELECT * FROM list WHERE last BETWEEN \'a\' AND \'m\' ORDER BY last";

$resultID = mysql_query($select);
 
$xml_output = "<?xml version=\"1.0\"?>
";
$xml_output .= "<lvl34>
";

for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
    $row = mysql_fetch_array($resultID);    
    //Escaping illegal characters
        $row['last'] = str_replace("&", "&", $row['last']);
        $row['last'] = str_replace("<", "<", $row['last']);
        $row['last'] = str_replace(">", "&gt;", $row['last']);
        $row['last'] = str_replace("\"", "&quot;", $row['last']);    
        $row['first'] = str_replace("&", "&", $row['first']);
        $row['first'] = str_replace("<", "<", $row['first']);
        $row['first'] = str_replace(">", "&gt;", $row['first']);
        $row['first'] = str_replace("\"", "&quot;", $row['first']);    
        $row['phone'] = str_replace("&", "&", $row['phone']);
        $row['phone'] = str_replace("<", "<", $row['phone']);
        $row['phone'] = str_replace(">", "&gt;", $row['phone']);
        $row['phone'] = str_replace("\"", "&quot;", $row['phone']);    

    //$xml_output .= "<person>" . $row['last'] . ", " . $row['first'] . "</person>
";

    $xml_output .= "<person>" . $row['last'] . ", " . $row['first'] . " - " . $row['phone'] . "</person>
";
    //$xml_output .= "<person title=\"" . $row['last'] . ", " . $row['first'] . " - " . $row['phone'] . "\"/>
";

}

//$xml_output .= "</item>";
$xml_output .= "</tenants>";

echo $xml_output;

```

i have a very basic understanding of all this stuff, so if anyone can set me on the right path that be awesome

thanks
