I generate XML files with GB2312 encoding by MySQL and PHP, because of chinese characters on my site.
It worked fine until I moved my website from a shared webhosting to an Ubuntu 16.04 VPS and installed Plesk.
Now all my XML files throw an encoding error and I assume, it's because of that GB2312 encoding.
Is it possible that the server doesn't recognize the encoding, when I installed everything through a standard Plesk installation?
If yes, is there a setting or a way to enable/install GB2312 encoding on my server?
<?php
header ("content-type: text/xml");
echo '<?xml version="1.0" encoding="GB2312"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">';
include 'connection.php';
mysqli_query($bd, "SET NAMES GB2312");
$query = mysqli_query($bd, "SELECT MAX(datum) as max_datum FROM apps") or die(mysqli_error());
$dateMAX = mysqli_fetch_assoc($query);
$date = $dateMAX['max_datum'];
$urls = mysqli_query($bd, "SELECT appID, title, id FROM apps WHERE id >= 1 AND id < 50000")or die(mysqli_error());
while ($string = mysqli_fetch_array($urls)) {
$title = $string['title'];
$titletrim = preg_replace('/[_%:"`\[\]\.\(\)%&-\'|!?\.,#‘<>]/s', '', $title);
$titleurl=str_replace(' ', '-', $titletrim);
?>
<url>
<loc>http://easitunes.com/<?php echo $titleurl."-".$string['appID']; ?></loc>
<lastmod><?php echo $date; ?></lastmod>
<changefreq>hourly</changefreq>
<priority>1</priority>
</url>
<?php
}
?>
</urlset>