After a webhook (XML) trigger, I have a PHP code doing the following treatment:
$xmlData = fopen('php://input' , 'rb');
while (!feof($xmlData)) { $xmlString .= fread($xmlData, 4096); }
fclose($xmlData);
file_put_contents('orders/order' . date('m-d-y') . '-' . time() . '.xml', $xmlString, FILE_APPEND);
And I also transfer this info to a database:
$xml = new SimpleXMLElement($xmlString);
$address1 = trim($xml->{'billing-address'}->address1);
$sql="INSERT INTO `Customers`(`address1`)
VALUES
('$address1')";
My problem is that character is not properly transported for the xml file and the database.
Original statement:
São Paulo
XML file saved on the server:
<?xml version="1.0" encoding="UTF-8"?>
<address1>São Paulo</address1>
Information on database (utf8_general_ci):
São Paulo
Everything seems to be proper set to UTF-8 but I still have this character problems.
When you establish database connection run the query:
That should help. Also make sure the data coming from your “web hook” is in that format.