l33cher Posted April 3, 2009 Share Posted April 3, 2009 Hello everybody, I'm posting this here because I'm not sure what the problem is. I have a site and all the files are saved with utf-8 encoding, the database is utf-8 + charset of the page is utf8 + everything seems to work fine. But from time to time when I refresh the page all of the text in the apears like "? ? ? ?" for no reason. It not constantly like this. Most of the time is working fine, but for no reason it just shits up. On my local computer I dont get that problem, but on the server its supposed to be hosted its like this. I'm note sure if it something with the apache configuration ... all of the other sites hosted on this server are cp1251 so nobody actually had the issue before. I cant change the server the site is hosted to. Has anybody seen a problem like this one. Btw the data that i get from the database ALWAYS works fine. The part where the text is from the document buggs but the text from the mysql work fine. I really dont know where to look for the problem. Regards, l33cher Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/ Share on other sites More sharing options...
Mchl Posted April 3, 2009 Share Posted April 3, 2009 Do you set the encoding for PHP-MySQL connection? Run SET NAMES 'utf8' query right after connecting to MySQL. Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-800096 Share on other sites More sharing options...
haku Posted April 3, 2009 Share Posted April 3, 2009 You need to save the document itself as utf-8. Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-800099 Share on other sites More sharing options...
l33cher Posted April 3, 2009 Author Share Posted April 3, 2009 Yes the document is utf-8 10000% sure + yes also make a query "SET NAMES 'utf8'" before anything else. But the problem is not the result i get from the mysql .. it seems fine. The problem is the text thats in the documents sometimes prints out like ? ? ?. Its not constants just from time to time. This happens on all browsers. Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-800101 Share on other sites More sharing options...
dgoosens Posted April 3, 2009 Share Posted April 3, 2009 this might be due to your Apache server indeed... if you can not change all the settings, try using ini_set('default_charset', 'UTF-8'); at the very beginning of your scripts... this will not affect the other sites hosted on the server Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-800104 Share on other sites More sharing options...
Yesideez Posted April 3, 2009 Share Posted April 3, 2009 I've experienced similar problems except right at the points where I'm including files (ie. header, menu, footer, side bar etc.) into the main page - at those points I get about 3 strange foreign characters and I've set all mine to UTF-8 as well. Will try this when I get home. Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-800110 Share on other sites More sharing options...
dgoosens Posted April 3, 2009 Share Posted April 3, 2009 I've experienced similar problems except right at the points where I'm including files (ie. header, menu, footer, side bar etc.) into the main page - at those points I get about 3 strange foreign characters and I've set all mine to UTF-8 as well. Will try this when I get home. this is because your files are saved in UTF-8 with BOM the 3 chars you see are the BOM... you should save your files in UTF-8 without BOM this is rahter easy with, for instance, notepad++ http://notepad-plus.sourceforge.net/uk/site.htm EDIT: more info on the byte order mark (BOM) http://en.wikipedia.org/wiki/Byte-order_mark Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-800112 Share on other sites More sharing options...
l33cher Posted April 3, 2009 Author Share Posted April 3, 2009 Nope .. with the ini_set its still doing the problem. the site is newman-bg.com you can check it out. Needs some refreshes. If you dont understand bulgarian just click on any link you find. The server admin has no idea and frankly i'm in a dead end too .. Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-800113 Share on other sites More sharing options...
dgoosens Posted April 3, 2009 Share Posted April 3, 2009 Nope .. with the ini_set its still doing the problem. the site is newman-bg.com you can check it out. Needs some refreshes. If you dont understand bulgarian just click on any link you find. The server admin has no idea and frankly i'm in a dead end too .. this does only happen in this part right: Актуални декори за интериорни решения 1783 PE Изберете страница: this looks like it is JavaScript... it looks like it is the JavaScript that is corrupting the chars... Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-800117 Share on other sites More sharing options...
Yesideez Posted April 3, 2009 Share Posted April 3, 2009 I've experienced similar problems except right at the points where I'm including files (ie. header, menu, footer, side bar etc.) into the main page - at those points I get about 3 strange foreign characters and I've set all mine to UTF-8 as well. Will try this when I get home. this is because your files are saved in UTF-8 with BOM the 3 chars you see are the BOM... you should save your files in UTF-8 without BOM this is rahter easy with, for instance, notepad++ http://notepad-plus.sourceforge.net/uk/site.htm EDIT: more info on the byte order mark (BOM) http://en.wikipedia.org/wiki/Byte-order_mark Thanks - I do indeed use Notepad++ (recently switched from Edit+) and the BOM is enabled - will disable it when I get home from work. I've had it appear in some instances of IE and never FF. Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-800120 Share on other sites More sharing options...
l33cher Posted April 3, 2009 Author Share Posted April 3, 2009 On other part of the site where there is more static text I remove the include ( cuz its an include from another file) and the same problem still exists. I thought it was the js part but .. when i removed it it still did the same thing. Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-800121 Share on other sites More sharing options...
dgoosens Posted April 3, 2009 Share Posted April 3, 2009 On other part of the site where there is more static text I remove the include ( cuz its an include from another file) and the same problem still exists. I thought it was the js part but .. when i removed it it still did the same thing. I had another look at the website... It does look this is a browser bug... Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-800125 Share on other sites More sharing options...
l33cher Posted April 3, 2009 Author Share Posted April 3, 2009 On other part of the site where there is more static text I remove the include ( cuz its an include from another file) and the same problem still exists. I thought it was the js part but .. when i removed it it still did the same thing. I had another look at the website... It does look this is a browser bug... It dose this on all browsers ... ff, ie, chrome .. Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-800130 Share on other sites More sharing options...
dgoosens Posted April 3, 2009 Share Posted April 3, 2009 damn... try this... To send all .js files as UTF8, simply add this line to your root .htaccess file: AddCharset utf-8 .js found this here: http://verens.com/archives/2006/05/05/some-utf8-problems-and-solutions/ Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-800136 Share on other sites More sharing options...
l33cher Posted April 3, 2009 Author Share Posted April 3, 2009 That didnt do the job :'( Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-800140 Share on other sites More sharing options...
dgoosens Posted April 3, 2009 Share Posted April 3, 2009 the problem is definitely coming from the JavaScript though... by going here http://newman-bg.com/special.php?idx=4 and refreshing as hell... I never got the ? ? ? ? ? ? ? ? by the way... after implementing the "AddCharset utf-8 .js" you should probably clear the cache of your browser... Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-800144 Share on other sites More sharing options...
dgoosens Posted April 3, 2009 Share Posted April 3, 2009 just thought of something... try putting header('Content-type: text/html; charset=utf-8'); at the top of your special.php script Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-800167 Share on other sites More sharing options...
l33cher Posted April 3, 2009 Author Share Posted April 3, 2009 nobody? Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-800190 Share on other sites More sharing options...
l33cher Posted April 3, 2009 Author Share Posted April 3, 2009 just thought of something... try putting header('Content-type: text/html; charset=utf-8'); at the top of your special.php script nope .. didnt work. Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-800198 Share on other sites More sharing options...
l33cher Posted April 6, 2009 Author Share Posted April 6, 2009 Would be nice if anybody else could give it a try. Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-802081 Share on other sites More sharing options...
haku Posted April 7, 2009 Share Posted April 7, 2009 If it's not text from the database, and only text that is hard coded into the page, then the problem is almost definitely the encoding of the document. Can't help you anymore than that though mate. Got a link to the page? Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-803188 Share on other sites More sharing options...
thebadbad Posted April 7, 2009 Share Posted April 7, 2009 the problem is definitely coming from the JavaScript though... by going here http://newman-bg.com/special.php?idx=4 and refreshing as hell... I never got the ? ? ? ? ? ? ? ? by the way... after implementing the "AddCharset utf-8 .js" you should probably clear the cache of your browser... I got them once when refreshing http://newman-bg.com/special.php?idx=4. But can't seem to make them appear again. To the OP: I was wondering if it had something to do with the encoding not being specified in the snippet http://newman-bg.com/special.php?idx=4 outputs. But I don't know what to do from there.. If that special.php part is the the only place the quirk occurs, I believe you could solve it by using HTML entities instead of the Unicode characters: Актуални декори за интериорни решения translates to Актуалнидекоризаинтериорнирешения Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-803250 Share on other sites More sharing options...
l33cher Posted April 8, 2009 Author Share Posted April 8, 2009 the problem is definitely coming from the JavaScript though... by going here http://newman-bg.com/special.php?idx=4 and refreshing as hell... I never got the ? ? ? ? ? ? ? ? by the way... after implementing the "AddCharset utf-8 .js" you should probably clear the cache of your browser... I got them once when refreshing http://newman-bg.com/special.php?idx=4. But can't seem to make them appear again. To the OP: I was wondering if it had something to do with the encoding not being specified in the snippet http://newman-bg.com/special.php?idx=4 outputs. But I don't know what to do from there.. If that special.php part is the the only place the quirk occurs, I believe you could solve it by using HTML entities instead of the Unicode characters: Актуални декори за интериорни решения translates to Актуалнидекоризаинтериорнирешения Nope .. the shit aint coming only from special.php .. if u click on ПРОДУКТИ and refresh the page several times u'll see that all of the page gets bugged except the data from the database. I understand that It should be a problem related to the documents encoding, but i dont understand how come it might work for a while and them for no reason bug? And also thing thing wont happen on my localhost .. I think i'll change all the encoding to cp1251 but still ..... someday I might need utf-8 for something and I'll be screwed. Link to comment https://forums.phpfreaks.com/topic/152344-strange-encoding-problem-utf-8/#findComment-804339 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.