• Hello!
    I use WordPress and I have problem retrieving data from another database.
    I’m not a developer and my english sucks ;-(

    A frienf of mine uses a 20 year old programm and from there he stores his data to a database ( using stripslashes() in his programm files). Tables type is MyISAM and the Collation: latin1_swedish_ci
    eg. ΠΡΩΤΑΘΛΗΑΜΑ ( translation = championship ) stored like ÐÑÙÔÁÈËÇÌÁ

    I recenlty install WordPress in a subfolder of his hosting using
    define(‘DB_CHARSET’, ‘utf8’);
    define(‘DB_COLLATE’, ”);
    on wp-config.php

    Evrything works fine with greek 4 me but now I want to get data from his old database 🙁

    Our server runs php 5.5.38, MySql 5.5.57 and Server charset: UTF-8 Unicode (utf8)

    I thought 2 solutions..

    1)Making a plugin. Fold!
    I copy & paste 3 files from his old site to /plugins/my-folder/

    The main file is initialize_database.php which sets the database pconnect info.
    The other 2 files are OnePage.php and OnePage.inc
    The OnePage.php includes initialize_database.php & OnePage.inc

    Everything was ÐÑÙÔÁÈËÇÌÁ until I insert to the start of OnePage.inc
    <HTML>
    <HEAD>
    <meta http-equiv=”Content-Type” content=”text/html; charset=windows-1253″>
    <TITLE>My Title</TITLE>
    <link rel=”stylesheet” href=”rollover” type=”text/css”>
    </HEAD>

    Now I have a page in WordPress with no stylesheet which uses charset=windows-1253 and shows my old database data in greek just fine. I also copied SecondPage.php & SecondPage.inc which get variables from One.Page and works too!

    2)My thought was that everything is simple now.
    I have to insert <meta charset=”windows-1253″ /> to the <head> section of my <header>.

    I’m using a child theme so I started by make a template-my_template.php file in my parent-theme/folder,
    which get_header( ‘my-new-header’ ); ?>
    Make a header-my-new-header.php in my child-theme/folder and content-new-content.php which in the includes initialize_database.php and OnePage.inc before the </article> tag.

    Made a new page using my-new-template and still retrives data in ÐÑÙÔÁÈËÇÌÁ.

    What am I doing wrong??

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter amensioto

    (@amensioto)

    I forget to mention that in my 2nd try,
    In header-my-new-header.php I typed
    <head>
    <meta charset=”windows-1253″ />

    instead of
    <head>
    <meta charset=”<?php bloginfo( ‘charset’ ); ?>” />

    Moderator bcworkz

    (@bcworkz)

    Your mistake is specifying and using windows-1253 on a UTF-8 site 🙂

    You should restore your template to the original charset and minimize and isolate where windows-1253 is used. Connect to the windows-1253 DB using a new wpdb connection object, where you can specify that the connection uses the charset appropriate for this DB. After you get data through this connection, immediately convert the data to UTF-8 by using mb_convert_encoding(). The data is now UTF-8 and you can mix it into other data from your site with no further concern about encoding.

    Thread Starter amensioto

    (@amensioto)

    $str = mb_convert_encoding($str, ‘utf-8′,’ISO-8859-7’)
    works fine

    Thanks!!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Problem with charset’ is closed to new replies.