Utf8 hassle

Discussion in 'PHP' started by nugis, May 17, 2009.

  1. #1
    Ive developed a locales system for my site, but its not working the way it should.
    Let me explain:
    1) This file decides which lang file to use (engine_locales_core.php):
    <?php session_start();
    $locale = array();
    $ename = $_COOKIE['user1'];
    if(!isset($_COOKIE['user1'])){
    	require_once "engine_locales_English.php";}
    elseif(isset($_COOKIE['user1'])){
      require_once "globalconfig.php";
      $getlang = mysql_query("SELECT language FROM users WHERE ename = '$ename'")or die(mysql_error());
       while($info = mysql_fetch_array( $getlang )){
        require_once "engine_locales_".$info['language'].".php";}}
      ?>
    Code (PHP):
    2) And then i simply echo the sentences:
    <?php require_once "engine_locales_core.php"; $locale = array(); ?>

    <?php echo $locale['0021']; ?>
    Code (PHP):
    Looks just fine when i load the page: äöüõ.
    But when i refresh it, these characters turn into: ????

    Whats up with that?
    Thanks for any help.
     
    nugis, May 17, 2009 IP
  2. rohan_shenoy

    rohan_shenoy Active Member

    Messages:
    441
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #2
    rohan_shenoy, May 17, 2009 IP
  3. yoavmatchulsky

    yoavmatchulsky Member

    Messages:
    57
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #3
    have you tried setting a content-type meta and header?

    header('Content-Type:...');

    also, i wouldn't trust data received from the user in the cookie. cookies can be changes. i wouldn't trust any input from the user. always validate.
     
    yoavmatchulsky, May 17, 2009 IP