XML not outputing properly from PHP - please look

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

$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

$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