Firefox PHP

Very olf Phorum upgrade charset problems

Posted by Ignas 
Very olf Phorum upgrade charset problems
March 15, 2017 08:41AM
Hello everyone,
I am struggling with our forum update. It was running fine (v 5.1.23) on very old machine (Apache 2.2.9, PHP 5.26).
But now, if I update it to 5.1.25 I get charset issues (No Lithuanian letters "ąčęėįšųū", but "æá" instead).

Any ideas?
Re: Very olf Phorum upgrade charset problems
March 15, 2017 08:50AM
Also I've tried to connect to the same database (on the old machine) with PDO based script on the same machine and a new one (Apache 2.4.10, PHP 5.6.30) and I get different results - script on the one old machine (PHP 5.26) echoes all symbols correctly, while on the new one (PHP 5.6.30) I get unreadable charecters.

The script is very simple:

<?php
$host = '192.168.0.209';
$db = 'phorum';
$user = 'forumas';
$pass = '*****';
$charset = 'utf8';

$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$opt = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false
];
$pdo = new PDO($dsn, $user, $pass, $opt);

$stmt = $pdo->query('SELECT * FROM phorum_forums');
while ($row = $stmt->fetch())
{
echo $row['forum_id'] . ' // ' . $row['description'] . "\n";
}

?>
Re: Very olf Phorum upgrade charset problems
March 15, 2017 08:52AM
It would help a lot if I'd knew what changed in Phorum version 5.1.25 regarding charsets and database connection.

Thanks a lot for help.
We are quite desperate here as forum is down since Sunday. And is quite popular.
Re: Very olf Phorum upgrade charset problems
March 15, 2017 09:30AM
Also, no matter how I try to clone this database, i dont get the same size (CLI dump, phpmyadmin, heidySQL, etc..)

Why is it so?

Also charset is weird (latin1_swedish_ci), any reason its not UTF8?
Re: Very olf Phorum upgrade charset problems
March 15, 2017 11:03AM
Hi Ignas,

please check which (default) collation you are using in mysql. My Phorum tables are using utf8_unicode_ci.

Regards
Oliver


Using Phorum since 7/2000: forum.langzeittest.de (actual version 5.2.23)
Modules "Made in Germany" for version 5.2: Author_as_Sender, CarCost, Close_Topic, Conceal_Message_Timestamp,
Format_Email, Index_Structure, Mailing_List, Pervasive_Forum, Spritmonitor, Terms_of_Service and German_Language_Files_Package.
Re: Very olf Phorum upgrade charset problems
March 15, 2017 11:23AM
Hi Oliver,
where I can find it?
mysql/my.cnf doesnt state default collation.
Re: Very olf Phorum upgrade charset problems
March 15, 2017 02:07PM
Hi Ignas,

do you use phpmyadmin?

Or

show table status like 'test';

where test is the table name. See: [dev.mysql.com]

Regards
Oliver


Using Phorum since 7/2000: forum.langzeittest.de (actual version 5.2.23)
Modules "Made in Germany" for version 5.2: Author_as_Sender, CarCost, Close_Topic, Conceal_Message_Timestamp,
Format_Email, Index_Structure, Mailing_List, Pervasive_Forum, Spritmonitor, Terms_of_Service and German_Language_Files_Package.
Re: Very olf Phorum upgrade charset problems
March 15, 2017 02:52PM
show table status like 'phorum_forums';
+---------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+---------------------+-------------------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+---------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+---------------------+-------------------+----------+----------------+---------+
| phorum_forums | MyISAM | 10 | Dynamic | 7 | 197 | 1380 | 281474976710655 | 5120 | 0 | 18 | 2007-06-27 16:02:08 | 2017-03-12 13:38:10 | 2017-03-12 21:57:37 | latin1_swedish_ci | NULL | | |
+---------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+---------------------+-------------------+----------+----------------+---------+
Re: Very olf Phorum upgrade charset problems
March 17, 2017 09:45AM
Hi Ignas,

to set the default character set for the database (replace "phorum" with your database name if it varies) before creating/importing:

ALTER DATABASE phorum CHARACTER SET utf8 COLLATE utf8_general_ci;

You have to check also the collation in your import script file.

Regards
Oliver


Using Phorum since 7/2000: forum.langzeittest.de (actual version 5.2.23)
Modules "Made in Germany" for version 5.2: Author_as_Sender, CarCost, Close_Topic, Conceal_Message_Timestamp,
Format_Email, Index_Structure, Mailing_List, Pervasive_Forum, Spritmonitor, Terms_of_Service and German_Language_Files_Package.
Sorry, only registered users may post in this forum.

Click here to login