I have an error that I have not been able to resolve.
Fatal error: Call to a member function appendChild() on null in /home/rgoad/map.checotahpolice.org/testfolder/index2.php on line 31
Line 31 [php]$crime->appendChild($emp);[/php]
Thank you in advance
[php]
$xml=new DomDocument(“1.0”,“UTF-8”);
$xml->formatOutput=true;
$xml->preserveWhiteSpace=false;
$xml->load(“cmap.xml”);
if(!$xml)
{
$crime=$xml->createElement(“crime”);
$xml->appendChild($crime);
}
else
{
$crime=$xml->firstchild;
}
if(isset($_POST[‘submit’]))
{
$fcrime=$_POST[‘a’];
$fdate=$_POST[‘b’];
$flat=$_POST[‘c’];
$flong=$_POST[‘d’];
$emp=$xml->createElement(“crime”);
$crime->appendChild($emp);
$a=$xml->createElement(“a”,“fcrime”);
$emp->appendChild($a);
$b=$xml->createElement(“b”,“fdATE”);
$emp->appendChild($b);
$c=$xml->createElement(“c”,“flat”);
$emp->appendChild($c);
$d=$xml->createElement(“d”,“flong”);
$emp->appendChild($d);
echo"".$xml->saveXML()."";
$xml->save(“cmap.xml”);
}
?>
[/php]