Jump to content

unable to set header information in php? 0o


Greywacke

Recommended Posts

hi all,i am unable to set the header information before the first response characters are echoed.here is the start of the php script:

<?php/*SIGN-UP MANAGER AJAX XML RESPONSEVersion 2.0.0~*/header("Content-type: text/xml; charset=utf-8");echo "<?xml version=\"1.0\" ?>\n";echo "<root>\n";//script is continued below...

i receive the following error in mozilla firefox 3.6.3:

Warning: Cannot modify header information - headers already sent by (output started at /home/dwtphovu/public_html/ferrety/fab/scripts/ajax_signup.php:1) in /home/dwtphovu/public_html/ferrety/fab/scripts/ajax_signup.php on line 6
how is this possible? 0o
Link to comment
Share on other sites

ahh the unicode characters defining it as utf-8 before the php... this screwed me around a bit no thanks to "unifier" lol...Unifier Websitethis issue is now resolved :)

Link to comment
Share on other sites

i still have to replace the left and right double quotes and accented characters though, despite the php files generating the xml being utf-8. the strings are pulled from a mysql database, with collation being found to be latin1_swedish_ci. converted to utf8_unicode_ci. did not work, still have to replace the unicode characters with xml entities as follows:

function xmlentities($value) {	if (is_array($value)) {		foreach ($value as $key => $val) {			$value[$key] = xmlentities($val);		}	} else {		$value = str_replace('&', '&', $value);		$value = str_replace('"', '"', $value);		$value = str_replace('<', '<', $value);		$value = str_replace('>', '>', $value);		$value = str_replace('“', '“', $value);		$value = str_replace('”', '”', $value);		$value = str_replace('é', 'é', $value);	}	return $value;}

would it help if the js files are utf-8, the form includes and all the php pages? that all the site's text files get saved as utf-8? javascript, css, html, php, etc. rather than just defining it in the meta-tags. this problem has arisen since the arise of firefox 3.6.3 - which i guess has a more intrinsic utf-8 unicode support.

Link to comment
Share on other sites

I think I've said it before, and I'll say it again, just in case... are you sure that your database's collation is utf8_unicode_ci or utf8_general_ci AND that on the PHP side, you've set the charset to UTF-8 with mysql_set_charset() every time you connect to the DB?Also, when outputting, consider replacing

header("Content-type: text/xml; charset=utf-8");echo "<?xml version=\"1.0\" ?>\n";

with

header("Content-type: application/xml");echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";

Doing those two things should result in future quotes and accented characters being read and written properly. If you currently already have lots of data, converting it might be tricky, but it's worth it.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...