i got error on this program sql_to_xml.php
<!DOCTYPE html>
<html>
<head>
<title>sql to xml convertor</title>
</head>
<body>
<form action="" method="POST">
<input type="text" name='mysql_host' placeholder="Host Name"><br>
<input type="text" name='mysql_user' placeholder="User Name"><br>
<input type="text" name='mysql_pass' placeholder="Password"><br>
<input type="text" name='db_name' placeholder="DataBase Name"><br>
<input type="text" name='table_name' placeholder="Table Name"><br>
<input type="submit" value="Sign-in" name="submit" />
</form>
<?php
if(isset($_POST["submit"])){
//database configuration
$mysql_host=$_POST['mysql_host'];
$mysql_user=$_POST['mysql_user'];
$mysql_pass=$_POST['mysql_pass'];
$db_name=$_POST['db_name'];
$table_name=$_POST['table_name'];
//connect to host
mysql_connect($mysql_host,$mysql_user,$mysql_pass);
//select database
@mysql_select_db($db_name) or die( "Unable to select database");
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
$root_element = $table_name."s"; //fruits
$xml .= "<$root_element>";
//select all items in table
$sql = "SELECT * FROM ".$table_name;
$result = mysql_query($sql);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
if(mysql_num_rows($result)>0)
{
while($result_array = mysql_fetch_assoc($result))
{
$xml .= "<".$table_name.">";
//loop through each key,value pair in row
foreach($result_array as $key => $value)
{
//$key holds the table column name
$xml .= "<$key>";
//embed the SQL data in a CDATA element to avoid XML entity issues
$xml .= "$value";
//and close the element
$xml .= "</$key>";
}
$xml.="</".$table_name.">";
}
}
//close the root element
$xml .= "</$root_element>";
//send the xml header to the browser
header ("Content-Type:text/xml");
//output the XML data
echo $xml;
}
?>
</body>
</html>