Hi all,
I've made a script to import data from a mySQL database into xml. Somethimes it crashes because of characters like '&' etc. Very annoying because ill have to delete the characters myself by hand......
How can i fix it??? here is the code
TnQ TanTrazz
I've made a script to import data from a mySQL database into xml. Somethimes it crashes because of characters like '&' etc. Very annoying because ill have to delete the characters myself by hand......
How can i fix it??? here is the code
Code:
<?php
header("Content-type: text/xml");
//to create connection to database
$connection = mysql_connect("localhost","username", "password")
or die ("could not connect to database");
//to select the database here test is the sample database come with mysql
$db = mysql_select_db("databasename",$connection)
or die ("Couldn't select database.");
$rs = mysql_query("select id, company, address, name, postalc, city, country, code from docu_request where behandeld='0'",$connection)
or die ("invalid query");
//count the no. of columns in the table
$fcount = mysql_num_fields($rs);
//you can choose any name for the starting tag
echo ("<result>");
while($row = mysql_fetch_array( $rs ) )
{
echo ("<tablerow>");
for($i=0; $i< $fcount; $i++)
{
$tag = mysql_field_name( $rs, $i );
echo ("<$tag>". $row[$i]. "</$tag>");
}
echo ("</tablerow>");
}
echo ("</result>");
?>
TnQ TanTrazz