Fork me on GitHub

Characterset problems in Zikula 1.2.7 and Mysql.  Bottom

  • Hi,
    I have a fresh install of Zikula 1.2.7. Just to get an option for Norwegian language I copied the locale/en to locale/no, and language/eng to language/nor. (Even if it still is english I at least have an option to transalte the needed things, and this has worked several times before)

    General information
    Zikula version: Zikula 1.2.7 (forest)
    Server information: Apache/2.2.13 (Unix) mod_ssl/2.2.13 OpenSSL/0.9.8g DAV/2 mod_jk/1.2.26
    PHP version: 5.3.1
    Database version: MySQL 5.0.51a-3ubuntu5.4 and MySQL client version: 5.0.51a

    My problem is that 2 different programs produces different output when comes to national characters, and this is working on another site, but obiously there ARE something different i cannot figure out.

    To illustrate my challenge I have combined the workig and failing code in the same PHP, and it looks like this:


    Code

    <?php
    if (!defined("LOADED_AS_MODULE")) {
             die ("You can't access this file directly...");
         }
    /*
        Produce and display 1st line
    */


    global  $strFrokostVareType;
    $ModName = basename(dirname(__file__));

    modules_get_language();
        $ModName = $GLOBALS['ModName'];

        $dbconn =& pnDBGetConn(true);
        $pntable =& pnDBGetTables();

        include_once("header.php");
       
        OpenTable();
    /*
        Produce and display 1st line (Code from working program)
    */
       
    $Vareliste1 = mysql_query("SELECT * FROM `MyTable` WHERE `Varenr` = 0") or die(mysql_error());

    while($row = mysql_fetch_array( $Vareliste1 ))
        {
            $strVareTypeTest2[] = $row['VareType'];
        }
    mysql_close();    
        echo "$strVareTypeTest2[0]";
        CloseTable();
       
    /*
        Produce and display 2nd line (Code from failing program)
    */
       
    mysql_connect('myhost','myuserid','mypassword') or die(mysql_error());
    mysql_select_db('mydbname') or die(mysql_error());

    $Vareliste2 = mysql_query("SELECT * FROM `MyTable` WHERE `Varenr` = 0") or die(mysql_error());  


    while($row = mysql_fetch_array( $Vareliste2 ))
        {
            $strVareTypeTest1[] = $row['VareType'];
        }

    mysql_close();

        echo "$strVareTypeTest1[0]";
        CloseTable();

        include_once('footer.php');

    ?>


    The two lines that are written out on my internetsite by this code is like this:
    Brød/Soft Basic (Uten gluten, laktose, gjær og nøtter)
    Br?d/Soft Basic (Uten gluten, laktose, gj?r og n?tter)[/code]

    Everything else on the site is nice with Norwegian characters, and also emails sent out is nice.

    So if anyone could give me a hint where to continue my search for this I would be for ever thankful!
    Have spent 2 days looking and trying without any success......
    icon_rolleyes
    Kind Regards!
  • It's not a problem of Zikula, it's a matter of setting the correct encoding to use with MySQL.

    Try adding

    Code

    mysql_query("SET NAMES 'utf8'");

    after mysql_select_db

    BTW, if your module was native for Zikula 1.2.x, you wouldn't have such problems with the encoding. But it seems that your module is way too old.
  • Hi and thanx for the respons!

    The extra lines solved my problem.

    I'm aware that code is old as You say, and I'm now updating myself on PHP/MYSQL AND the Zikula system.
    I have found good documentation on the Zikula site how to code modules, and I'm looking into that now.

    If You have some good "hint & tips" for me that might be helpful on this matter I will be thankful for that.

    But again; thanx for Your help on this.

    Kind Regards,

    Seldom_Seen.
  • Take a brief look at the docs here.

    I would then suggest to study a core module (maybe search or groups) or even copy it and start making your own. We are here to help you in case you need something icon_smile

    Happy coding!
  • 0 users

This list is based on users active over the last 60 minutes.