...

View Full Version : Weird characters showing up in query result



Jacobb123
03-03-2009, 03:30 AM
I am trying to display text on my site but can't figure out why it is coming out with weird characters. It is a text in spanish that I have inserted with joomla and am trying to display also in another page by taking it directly from the DB

Here is the code I am using:


if($newsStory['introtext'] == ''){ $newsText = "<br><br><br>"; }else{$newsText = htmlentities($newsStory['introtext']);}


here is the output


<br />En cuanto a lo que se refiere a la m� popular, Medell�ha sido considerado el para� de los dinosaurios olvidados. No es gratuito. Si repasamos las cr�as de los �os cuarenta a�&nbsp; esta ciudad ha acogido en forma maravillosa, entusiasta, rotunda a muchos artistas que ya reposaban en los fr� cuarteles&nbsp; del ostracismo, artr�cos por la nostalgia de aplausos, anquilosados por falta de reconocimiento y admiraci�br /&gt;<br />


and


<p>Cuando fue publicada la obra �la historia sin fin� del alemn Michael Ende, estamos hablando ah por los aos ochenta, todo el mundo auguraba un gran xito de la misma en las taquillas cinematogrficas. La verdad es que no pas de ser una pompa de jabn inmersa en un kitsch empalagoso de envergaduras aberrantes. A todos aquellos que habamos ledo la obra apasionadamente, ms de 3 veces nos daba nauseas apenas recordar la �bendita� pelcula. �Como evitar que un nio lea un libro� sea quizs el ttulo ulterior de la misma.</p>

in the second paragraph the question marks should come out as double quotes and I have no clue what the first paragraph is doing.

Can someone clue me in.

I have tried htmlspecialcharacters to no avail

oesxyl
03-03-2009, 03:45 AM
is a encoding problem. htmlspecialchars have nothing to do with the charset you use.

try something like this:

http://www.php.net/manual/en/book.mbstring.php

best regards

Jacobb123
03-03-2009, 04:16 AM
The charset is utf-8 and It should work just fine with that. It was also saved in the DB as utf-8. So I am at a loss. if I use htmlentities with the text it comes out fine but not the double quotes.

oesxyl
03-03-2009, 04:41 AM
The charset is utf-8 and It should work just fine with that. It was also saved in the DB as utf-8. So I am at a loss. if I use htmlentities with the text it comes out fine but not the double quotes.
can you post a link to the page?

best regards

Jacobb123
03-03-2009, 04:42 AM
wetito.com is the page in qestion

oesxyl
03-03-2009, 04:55 AM
wetito.com is the page in qestion

http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fwetito.com%2F


Sorry, I am unable to validate this document because on line 276 it contained one or more bytes that I cannot interpret as utf-8 (in other words, the bytes found are not valid values in the specified Character Encoding). Please check both the content of the file and the character encoding indication.

The error was: utf8 "\x93" does not map to Unicode

you have this before doctype:



<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-2808766-1";
urchinTracker();
</script>


move it iniside the page and see if fix the problem.

best regards

Jacobb123
03-03-2009, 05:16 AM
no that did not fix the problem

oesxyl
03-03-2009, 05:36 AM
no that did not fix the problem
the response of the server is a iso-8859-1 not utf-8:
change it to utf-8:


<meta http-equiv="Content-Type" content="text/html; charset = iso-8859-1" />

anyway I guess this will not fix the problem. Is something in your code, between the place where you get the data from mysql and the place where you output in the page who change encoding and broke the content. I assume that what you get from mysql is correct as you said. Probably is a good idea to check this assumption before anything else.

best regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum