Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6933899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:53:29+00:00 2026-05-27T11:53:29+00:00

I have created this php script, to create an xml-file from my database: <?php

  • 0

I have created this php script, to create an xml-file from my database:

<?php
header("Content-type: text/xml");
header("Expires: Mon, 26 Jul 1990 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

$host = "localhost";
$user = "root";
$pass = "root";
$database = "flexapp";

$charToReplace = array("é", "è", "ê");
$charReplacements = array("e", "e", "e");

$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($database, $linkID) or die("Could not find database.");

$query = "SELECT * FROM artists";
$artist_result = mysql_query($query, $linkID) or die("Data not found.");

$xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$xml_output .= "<artists>\n";

for($x = 0 ; $x < mysql_num_rows($artist_result) ; $x++){
    $itemrow = mysql_fetch_assoc($artist_result);
    $xml_output .= "\t<artist>\n";
    $xml_output .= "\t\t<id>" . $itemrow['pk_artist_id'] . "</id>\n";
    $itemrow['artist_name'] = str_replace($charToReplace, $charReplacements,         $itemrow['artist_name']);
    $xml_output .= "\t\t<name>" . $itemrow['artist_name'] . "</name>\n";
    $xml_output .= "\t\t<picture>" . $itemrow['artist_pic'] . "</picture>\n";
    $xml_output .= "\t\t<twitter>" . $itemrow['artist_twitter'] . "</twitter>\n";
    $xml_output .= "\t</artist>\n";
}
$xml_output .= "</artists>\n";
echo $xml_output;
?>

I try to replace characters like é en ê to e.

But it gives this error in the browser:

This page contains the following errors:

error on line 23 at column 9: Encoding error

This is the xml that is outputted:

<?xml version="1.0" encoding="UTF-8"?>
<artists>
<artist>
    <id>1155</id>
    <name>Have Heart</name>
    <picture>http://userserve-ak.last.fm/serve/126/29086375.jpg</picture>
    <twitter></twitter>
</artist>
<artist>
    <id>1156</id>
    <name>Dead Swans</name>
    <picture>http://userserve-ak.last.fm/serve/126/4781939.jpg</picture>
    <twitter></twitter>
</artist>
<artist>
    <id>1157</id>
    <name>Nirvana</name>
    <picture>http://userserve-ak.last.fm/serve/126/3991355.jpg</picture>
    <twitter></twitter>
</artist>
<artist>
    <id>1158</id>
    <name>Touchter>
</artist>

But the last one (the name in the database is Touché Amoré) should be like all the rest, but somehow the strings aren’t being replaced.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:53:29+00:00Added an answer on May 27, 2026 at 11:53 am

    This may be an issue with encoding the data before printing. Try using utf8_encode() and htmlentities()

    function xmlencode($data) {
        $data = utf8_encode($data);
        $data = htmlentities($data);
        return $data;
    }
    

    and then

    ...
    $xml_output .= "\t\t<picture>" . xmlencode($itemrow['artist_pic']) . "</picture>\n";
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created this report using BIRT and phpjavabridge <?php header(Content-type: application/pdf); header(Content-Disposition: inline;
I have a PHP script that loads XML content dynamically: require_once 'directory/directory/'; $nice= '1149632';
This script creates a new XML file with the original data and doesn't have
In the past I have created a php file that generates the XML and
i have created a module with this among others this function in it: <?php
I have created an index on my table like this: CREATE INDEX index_typ_poplatky ON
I have create a simple grid that retrieves data from a server through php.
I have created a lottery script in php. My problem is now selecting more
I created a small script I use for 'cleaning' sitemap file from certain links.
I need to create a PHP script that receives XML input via an HTTP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.