SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Carachters converted to <?> !

    Hello,

    I have a PHP/ MYSQL driven content website in which I have alot of latin characters in the MySQL Tables....

    Now in PHPMYADMIN the characters show up fine.....But on my website My characters are converted into <?> in my web pages.

    I have converted all my files to utf-8... still no luck.

    Can anyone please help?

    Many thanks,
    MDiogo

  2. #2
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    Check in your browser, what does it say the character encoding is?

    In Firefox: View -> Character Encoding

    If that's not what you expect (I think utf8?) then you may need to send some additional headers to get the browser to use the correct encoding.

    For PHP, something like this should work:

    PHP Code:
    header('Content-Type: text/html; charset=UTF-8'); 

  3. #3
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, my Character Encoding seems to be the correct, Unicode UTF-8. Still some characters appear has ��

    Can't find the cause for this, any more help or something you could remember would be great.

  4. #4
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    OK, next step is to check the collation of the database.

    Before you retrieve your data, try executing this query:

    Code:
    SET NAMES utf8;

  5. #5
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello Immerse, I have executed the query at phpMyAdmin, no luck, everything stays the same.

  6. #6
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    No, you need to do this in your PHP application.

    Whenever you create a new connection to the database, you should execute that query.

    For example:
    PHP Code:
    $conn mysql_connect('host''user''pass');
    mysql_query('SET NAMES utf8'$conn); 

  7. #7
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello again Immerse, thanks for the support. I have made that change but gives me an error, I believe I am making some sintax mistake.

    This is how i'm doing my connection:

    PHP Code:
    <?php
    $dbname
    ="*****"// Indique o nome do banco de dados que será aberto   
    $usuario="*****"// Indique o nome do usuário que tem acesso
    $passsql="*****"// Indique a senha do usuário
    foreach($_POST AS $key => $value) { ${$key} = $value; }
    foreach(
    $_REQUEST AS $key => $value) { ${$key} = $value; }
    function 
    res($id,$sql,$erro 1) {
        if(empty(
    $sql) OR !($id))
           return 
    0//Erro na conexão ou no comando SQL
       
    if (!($res = @mysql_query($sql,$id))) { if($erro)
            echo 
    "Ocorreu um erro na execução do Comando SQL no banco de dados. Favor Contactar o Administrador.<br>QUERY: $sql";
          exit;} return 
    $res;}
    if(!(
    $id mysql_connect($_ENV{DATABASE_SERVER},$usuario,$passsql))) {
       echo 
    "Não foi possível estabelecer uma conexão com o gerenciador MySQL. Favor Contactar o Administrador.";
       exit;
    }
    //2º passo - Seleciona o Banco de Dados
    if(!($con=mysql_select_db($dbname,$id))) {
       echo 
    "Não foi possível estabelecer uma conexão com o gerenciador MySQL. Favor Contactar o Administrador.";
       exit;
    }
    ?>
    Can you kindly show me how can I make that change on the script?

    Can't this script be a little more clear?

    Many thks,
    Mário

  8. #8
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Immerse, i'm on my way, I got it fixed using the query you provided, I also changed the way I'm connecting to something more clear on the code.

    Many thks M&#225;rio.


Bookmarks

Posting Permissions

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