Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Aug 2006
    Posts
    311
    Thanks
    0
    Thanked 1 Time in 1 Post

    Weird characters showing up in query result

    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:

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

    here is the output

    Code:
    <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

    Code:
    <p>Cuando fue publicada la obra �la historia sin fin� del alemán Michael Ende, estamos hablando ahí por los años ochenta, todo el mundo auguraba un gran éxito de la misma en las taquillas cinematográficas. La verdad es que no pasó de ser una pompa de jabón inmersa en un kitsch empalagoso de envergaduras aberrantes. A todos aquellos que habíamos leído la obra apasionadamente, más de 3 veces nos daba nauseas apenas recordar la �bendita� película. �Como evitar que un niño lea un libro� sea quizás el título 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

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    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

  • #3
    Regular Coder
    Join Date
    Aug 2006
    Posts
    311
    Thanks
    0
    Thanked 1 Time in 1 Post
    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.

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Jacobb123 View Post
    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

  • #5
    Regular Coder
    Join Date
    Aug 2006
    Posts
    311
    Thanks
    0
    Thanked 1 Time in 1 Post
    wetito.com is the page in qestion

  • #6
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Jacobb123 View Post
    wetito.com is the page in qestion
    http://validator.w3.org/check?verbos...Fwetito.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:

    Code:
    <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

  • #7
    Regular Coder
    Join Date
    Aug 2006
    Posts
    311
    Thanks
    0
    Thanked 1 Time in 1 Post
    no that did not fix the problem

  • #8
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Jacobb123 View Post
    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:
    Code:
    <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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •