Incorect characters on page.

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
p.m.
New Member
New Member
Posts: 4
Joined: Thu Jun 14, 2007 9:15 am

Incorect characters on page.

Post by p.m. »

Hi, I'm using cmsms 1.2.3 (currently upgraded to 1.2.4), php 5.0.45, mysql 5.0.45 on provider server (php is running in safe mode - but i can live with that).

Everything is setup to use utf-8 encoding.

I have problem with some locale characters, they are displayed incorrectly. This set 'áÁčČďĎéÉíÍĺĹľĽňŇóÓôŕŔřŘ?šŠťŤúÚýÝžŽ' is displayed as 'á�?čČďĎéÉíÍĺĹľĽ�?ŇóÓôŕŔř�?šŠťŤúÚýÝžŽ' - it is displayed this way also in editing mode, either using WYSIWYG or without. However when I opened mysql database and find the string for the page it seems that it is written correctly.

I also tried to write those characters 'ňÁŘ' using html escape sequence 'ňÁŘ'. In this case they are displayed correctly, but as soon as I edit the same page they are displayed directly (without escape sequence but correctly) and after updating the page they are displayed incorrectly '�?�?�?'.

In the past I was playing with cmsms (some older version) and never noticed something like this. Also I googled for some sites using cmsms with 'sk_SK' language and they display some of those characters correctly but they use older versions like 1.0.x.

Maybe I am missing something or something is not correctly configured. Please help. Thanks.
Pierre M.

Re: Incorect characters on page.

Post by Pierre M. »

May be webserver or browser encoding ? Can you track http headers, meta information... and try vanilla 1.2.4 ?

Pierre M.
p.m.
New Member
New Member
Posts: 4
Joined: Thu Jun 14, 2007 9:15 am

Re: Incorect characters on page.

Post by p.m. »

Thanks Pierre for the reply...

I tried to install and test vanilla 1.2.4 on the same server and it runs just fine without any problems.

I also tried to type those characters in menu, news, etc. and the output was grambled.

I do not think it has something to do with browser encoding, I use FireFox 2.0.0.13 (it shows utf-8 encoding), also tried IE.

I found my account info to some old project using older version of cmsms on some free web server and tested all characters there and it was correct. Then on that server I copied brand new version 1.2.4 and connected to the same database and it worked just fine. Probably it has nothing to do with version. I will investigate further and post http headers and meta info later.

...

I compared the 2 databases - for vanilla and cmsms and they look similar, encoding of DB, encoding of fields, collations, etc. But I found one difference when inspecting values of tables using phpMyAdmin: values in CMSMS DB were not displayed directly as UTF-8 but for special characters there were 2 characters (I thought it is normal this way, I am familiar with utf-8 and know a bit it's encoding), but in Vanilla DB were all characters displayed correctly with encoding (as single characters with accents etc.). I suspect that there is something with DB which was there from the beggining, probably created by provider. I will try to recreate the DB with the data...
p.m.
New Member
New Member
Posts: 4
Joined: Thu Jun 14, 2007 9:15 am

Re: Incorect characters on page.

Post by p.m. »

Hello again...

I exported DB (unfortunately data was not exported correctly in utf8, except notes etc.), corrected characters (to utf8) and imported back to new DB. It shows just fine in phpMyAdmin (I tried to export it again and the data are correctly encoded in utf8 format). I reconected CMSMS to the new DB and result is even worse.

I checked http meta info and everything looks just fine: utf8 encoding...

I suspect there is some problem with DB connection and maybe PHP safe mode. How can I easily run some php script to get and display some data from DB the same way as CMSMS does?

Then I tried to insert some text in News module and it has the same problem. All characters shows fine except 'ňÁŘ', but in the DB they are written incorrectly, phpMyAdmin shows 'ľščťžýáíéúäôĹ?Ă?Ĺ?' instead of 'ľščťžýáíéúäôňÁŘ' and CMSMS output shows 'ľščťžýáíéúäô�?�?�?'.
p.m.
New Member
New Member
Posts: 4
Joined: Thu Jun 14, 2007 9:15 am

Re: Incorect characters on page.

Post by p.m. »

I made a simple script to verify what should be done to correctly read and output data from utf-8 encoded DB:

Code: Select all

<?php
// note this script is placed in tmp folder, co config.php is one level up
include '../config.php';

header('content-type: text/html; charset: utf-8');

echo	'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ' .
	'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> ' .
	'<__html xmlns="http://www.w3.org/1999/xhtml" xml:lang="sk" lang="sk"> ' .
	'<head> ' .
	'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> ' .
	'</head></__body> ';

$db_name = 'do950101db'; // real utf-8 copy of original db

$conn = mysql_connect($config['db_hostname'], $config['db_username'], $config['db_password']) or 
	die ('Error connecting to mysql');

mysql_select_db( $db_name );

mysql_query("SET character_set_results=utf8", $conn);

$query  = "SELECT * FROM `cmsfalange_content`";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
    echo "<p> content_id :{$row['content_id']} <br>" . 
	"content_name :{$row['content_name']} <br>" .
         "menu_text : {$row['menu_text']} </p><br>";
}

mysql_close($conn);

echo	'<__body>';
?>
however I found out that probably CMSMS is not really using utf-8 (as PHP is not) - that's why all what is written to DB does not appear as utf-8. I checked also the DB on another server which seems to run correctly, but the data are not encoded in utf-8. It somehow works when the data does not change somewhere on the way (they are utf-8 only at endpoints = when editing and when html is generated)... But in my case probably something happens with some special characters on the way and the are grambled then.

Any advice? Or am I completely wrong?
Locked

Return to “CMSMS Core”