View Full Version : é is causing a parsing error?
Tim Mousel
08-17-06, 05:58 PM
Hi,
Please look here:
http://www.rental-script.com/review/rss/rss.xml
The word "Murciélago" is causing the error.
Here is the code used to display the title:
<title><? print htmlentities($title,ENT_QUOTES); ?></title>
What do I need to do differently so that the "é" won't cause an error?
Thanks,
Tim
Add the following before outputting anything to the browser.
header('Content-type: text/xml; charset=iso-8859-1');
And this before the <rss version="2.0">
echo '<?xml version="1.0" encoding="iso-8859-1"?>' ."\r\n";
EDIT:
I just see.. it's an XML document. Try just adding the second piece of code I posted. If this doesn't work try placing the content between <![CDATA[ content here ]]> wrappers.
EDIT 2:
You will have to take out the htmlentities() using the method above.
Tim Mousel
08-17-06, 06:12 PM
Hi,
Thanks for the reply.
I tried that and it didn't work for me. Here is the complete code I'm using:
<?
include ("../functions.php");
include ("../f_secure.php");
include ("../config.php");
$limit = 50;
header('Content-type: text/xml');
//header('Content-type: text/xml; charset=iso-8859-1');
?>
<xml version="1.0" encoding="iso-8859-1">
<rss version="2.0">
<channel>
<title>Five Star Review Script</title>
<description>Amazon-style script enables users to review products</description>
<link>http://www.review-script.com/</link>
<?
$sql = "select * from review_items WHERE item_name != '' order by item_id limit $limit";
$result = mysql_query($sql)
or die(sprintf("Couldn't execute query, %s: %s", db_errno(), db_error()));
//$query = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
$title = stripslashes($row["item_name"]);
$desc = stripslashes($row["item_desc"]);
$item_id = $row["item_id"];
$category = stripslashes($row["category"]);
//$pubDate = date(d, m, y h:s:s);
//Wed, 02 Oct 2002 13:00:00 GMT
// output to browser
?>
<item>
<title><? print htmlentities($title,ENT_QUOTES); ?></title>
<description><? print htmlentities($desc,ENT_QUOTES); ?></description>
<category><? print htmlentities($category,ENT_QUOTES); ?></category>
<link><? print htmlentities($url,ENT_QUOTES); ?><? print htmlentities($directory,ENT_QUOTES); ?>/index2.php?item_id=<? print $item_id; ?></link>
</item>
<?
}
?>
</channel>
</rss>
Thanks for your help.
Tim
Hm, actually, I'm not having problems, leaving the encoding type out, and leaving the characters as they are. Without htmlentities()...
I'm gonna move this to the XML forum...
Tim Mousel
08-17-06, 06:22 PM
Actually, I just tried it in IE and it works fine. When I view it in Firefox, I get this error:
XML Parsing Error: undefined entity
Location: http://www.rental-script.com/review/rss/rss.xml
Line Number 266, Column 27: <title>Lamborghini Murciélago</title>
That's strange.
Tim
Try taking out all the htmlentities() and the encoding type that I gave you in my first post. It works for me on Firefox.
Tim Mousel
08-17-06, 06:38 PM
Hi,
Still getting errors. Are you suggesting that my final code look like this?
<?
include ("../functions.php");
include ("../f_secure.php");
include ("../config.php");
$limit = 50;
header('Content-type: text/xml');
?>
<rss version="2.0">
<channel>
<title>Five Star Review Script</title>
<description>Amazon-style script enables users to review products</description>
<link>http://www.review-script.com/</link>
<?
$sql = "select * from review_items WHERE item_name != '' order by item_id limit $limit";
$result = mysql_query($sql)
or die(sprintf("Couldn't execute query, %s: %s", db_errno(), db_error()));
//$query = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
$title = stripslashes($row["item_name"]);
$desc = stripslashes($row["item_desc"]);
$item_id = $row["item_id"];
$category = stripslashes($row["category"]);
// output to browser
?>
<item>
<title><? print $title; ?></title>
<description><? print $desc; ?></description>
<category><? print $category; ?></category>
<link><? print $url; ?><? print $directory; ?>/index2.php?item_id=<? print $item_id; ?></link>
</item>
<?
}
?>
</channel>
</rss>
Thanks,
Tim
Try this
<item>
<title><![CDATA[<? print $title; ?>]]></title>
<description><![CDATA[<? print $desc; ?>]]></description>
<category><? print $category; ?></category>
<link><? print $url; ?><? print $directory; ?>/index2.php?item_id=<? print $item_id; ?></link>
</item>
vBulletin® v3.6.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.