Jump to content

UTF_8 problem


aram
 Share

Recommended Posts

Hi i have a problem with UTF_8, i must save my files in UTF-8 but i have this code which its RSS file but when i load a file it says

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\mysite\rss.php:1) in C:\xampp\htdocs\mysite\rss.php on line 29
And here is my code:
<?php$database =  "mydatabase";$dbconnect = mysql_pconnect("localhost", "root","");mysql_select_db($database, $dbconnect);$query = "select link, title news from `news` limit 15";$result = mysql_query($query, $dbconnect);while ($line = mysql_fetch_assoc($result))		{			$return[] = $line;		}$output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>			<rss version=\"2.0\">				<channel>					<title>mysite</title>					<link>mysite/rss.php</link>					<description>A Test RSS</description>					<language>en-us</language>					<docs>http://someurl.com</docs>			";		   foreach ($return as $line){	$output .= "<item><title>".htmlentities($line['title'])."</title>					<link>".htmlentities($line['link'])."</link>				  <description>".htmlentities(strip_tags($line['news']))."</description>				</item>";}$output .= "</channel></rss>";header("Content-Type: application/rss+xml");echo $output;?>

Link to comment
Share on other sites

It means that any output has been sent to browser already. as from your code i cant see anything that produce a output before sending a header. is that the complete code which one is not working? make sure there is no output before sending header, even a blank space

Link to comment
Share on other sites

It means that any output has been sent to browser already. as from your code i cant see anything that produce a output before sending a header. is that the complete code which one is not working? make sure there is no output before sending header, even a blank space
Thats the complete code its all, but my problem is im saving my documents in UTF-8 and i have to, but when i save the document in ANSI there is not problem with HEADER but it not outputs my datas that in UTF_8
Link to comment
Share on other sites

try changing the charset in header to UTF-8header("Content-Type: application/rss+xml; charset=utf-8");

Edited by birbal
Link to comment
Share on other sites

try changing the charset in header to UTF-8header("Content-Type: application/rss+xml; charset=utf-8");
nothing changed.and i have added this code after the 3rd line but not fixed, i had the same problem in past i have fixed it with thi little code but its not works with this one
mysql_query('SET NAMES utf8');

Edited by aram
Link to comment
Share on other sites

is that the file is saved with utf-8 encoding?

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\mysite\rss.php:1) in C:\xampp\htdocs\mysite\rss.php on line 29
Do you still see it?what is happeing when you run the sript?.what do you see there?
Link to comment
Share on other sites

is that the file is saved with utf-8 encoding?Do you still see it?what is happeing when you run the sript?.what do you see there?
Samething that i wrote first nothing changes
Link to comment
Share on other sites

You have to specify what you are seeing when you run the code. as we are not running the code so we cant see what is happening ,so all is depend upon your response which will help us to help you. its hard to fix anything without knowing what is not working. does the $output is showing properly?

Edited by birbal
Link to comment
Share on other sites

You have to specify what you are seeing when you run the code. as we are not running the code so we cant see what is happening ,so all is depend upon your response which will help us to help you. its hard to fix anything without knowing what is not working. does the $output is showing properly?
i thought i answered your question! i said its the same thing nothing changed here its the output
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\mysite\rss.php:1) in C:\xampp\htdocs\mysite\rss.php on line 29
Thanks for your answers :) Edited by aram
Link to comment
Share on other sites

That error message says that there is output on line 1 of the rss.php file. If there is a blank line on line 1, that's a problem. If there is a doctype, or XML preamble, or anything at all before the PHP tag, that's the problem.If there's none of that, it sounds like you're running into the BOM issue, where the BOM is being saved at the beginning of the file. If that's the case, then you need to save the file without the BOM. Your editor may have options like that when saving UTF files.

Link to comment
Share on other sites

That error message says that there is output on line 1 of the rss.php file. If there is a blank line on line 1, that's a problem. If there is a doctype, or XML preamble, or anything at all before the PHP tag, that's the problem.If there's none of that, it sounds like you're running into the BOM issue, where the BOM is being saved at the beginning of the file. If that's the case, then you need to save the file without the BOM. Your editor may have options like that when saving UTF files.
Thanks my friend, There is no blank line and there is no doctype. My problem is this BOM, Im using notepadd++ when i save the file witout the BOM this problem resolves, but those datas that its utf-8 that works with my language (Kurdish) outputs nothing, outputs this words that in English. Edited by aram
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...