I have a Function (within the class Database)
function locTo (){//return the location of the to currency
$con = dbconnect(); //instantiate db connection
$locationTo= mysql_query ("SELECT location FROM Sheet1 where currency_code = '$this->to'", $con);
$lol = mysql_fetch_array($locationTo);
return $lol['location'];
mysql_close();
}
when I call the function
$foo = new Database($from,$to);
$hey = $foo->LocTo();
echo $hey;
or
$foo = new Database($from,$to);
echo $foo->LocTo();
It out puts correctly.
Im trying to put into XML and im getting an encoding error.
This is my XML
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<conv>';
echo'<at>'.$timefrom.'</at>';
echo'<rate>'.$rate.'</rate>';
echo'<from>';
echo'<code>'.$from.'</code>';
echo'<curr>'.$currencyFrom.'</curr>';
echo'<loc>'.$locFrom.'</loc>';
echo'<amnt>'.$amount.'</amnt>';
echo'</from>';
echo'<to>';
echo'<code>'.$to.'</code>';
echo'<curr>'.$currencyTo.'</curr>';
echo'<loc>'.$locTo.'</loc>';
echo'<amnt>'.$convertedAmount.'</amnt>';
echo'</to>';
echo'</conv>';
Does anyone know why I am getting an encoding error? I have checked the source code and it gets as far as the location.
here is an example of the location out put.
AED to GBP
United Arab Emirates
United Kingdom, Crown Dependencies (the Isle of Man and the Channel Islands), certain British Overseas Territories ( South Georgia and the South Sandwich Islands, British Antarctic Territory and British Indian Ocean Territory)
I recommend switching to (for example) DOM so your code would look like this:
This should make your XML always valid. The result would look like (filled just with string
'time'):Take a look at last
<amnt />it’s correctly “xml escaped”, you don’t have to worry about it anymore, but be careful when usingDOMELement->noveValue = htmlAFAIK this doesn’t escape your values.And of course don’t forget to set correct
header(), use (before sending any output):Also take a look at 14.17 Content-Type and MIME types on wiki.