Kiril Karakterler RSS PHP MySQL

0 Cevap php

I'm trying to write a RSS feed for a website which mostly has Russian articles, though sometimes English. The site is built with php mysql. This is what the text looks like when I visit the url:

Áåñåäà "Èçðàèëü è IU" öèêëà 1 EC ¹

What am I doing wrong? Also, I'm tryn to add this line of code on top of the document but it breaks it and I get an error:

<?xml version="1.0" encoding="UTF-8"?>

Here is my php code excluding the database connect info. I'm desperate. Please help.

<?php
require_once ('cutils/db_connect.php3');
// PHP file that renders perfect Dynamic XML for MySQL Database result sets
// Script written by Adam Khoury @ www.developphp.com - April 05, 2010
// View the video that is tied to this script for maximum understanding
// -------------------------------------------------------------------
header("Content-Type: rss-http;"); //set the content type to xml
// Initialize the xmlOutput variable

$xmlBody = '
<rss version="2.0">

<channel>
<title>Name of your site</title>
<description>A description of your site</description>
<link>http://yoururl.com/</link>
<copyright>Your copyright information</copyright>';
// Connect to your MySQL database whatever way you like to here
mysql_connect("localhost","dbuser","dbpass") or die (mysql_error());
mysql_select_db("sinaius2_em") or die ("no database");
// Execute the Query on the database to select items(20 in this example)
$sql = mysql_query("SELECT `id`, `title`, `article_text`, `article_date` FROM `articles`ORDER BY `article_date` DESC LIMIT 0 , 15");
mysql_query("SET NAMES utf8");
while($row = mysql_fetch_array($sql)){
    // Set DB variables into local variables for easier use 
    $id = $row["id"]; 
    $title = $row["title"] ;  
    $date_time = strftime("%b %d, %Y", strtotime($row["article_date"])); 
    $description = $row["article_text"];  
    // Start filling the $xmlBody variable with looping content here inside the while loop 
    // It will loop through 20 items from the database and render into XML format
    $xmlBody .= "
<item> 
    <title>$title</title>
    <description>TEST</description>  
    <pubDate>$date_time</pubDate>
    <link>http://www.evreimir.com/article.php?id=$id</link> 
</item> ";
} // End while loop
mysql_close(); // close the mysql database connection_aborted
$xmlBody .= "</channel>
</rss>";
echo $xmlBody; // output the gallery data as XML file for flash
?>

0 Cevap