2

Many years ago I built www.preservng-football-history.com. Lately my hosting company upgraded to PHP 5.6 and besides some PHP coding issues (deprecated functions etc...) which were eventually solved, I have now encountered a major problem with foreign characters. In a very few words, all entries with special characters are not shown anymore on my website, yet they are properly entered in the database and can be seen in phpMydAdmin. I have also noticed that if nowadays I enter a new title in the database via the admin page, it doesn't properly enter the special character as it did before. For instance, München is now entered as München (in the past it was entered via CVS spreadsheet as München). I am lost. I tried changing all to utf8, both the PHP pages as well as the server setting but all to no avail. Does anyone know what PHP 5.6 did suddenly cause that ?

Database call code:

function db() {
    global $glob;
    $this->db = @mysql_connect($glob['dbhost'], $glob['dbusername'], $glob['dbpassword']);
    if (!$this->db) die ($this->debug(true));
    if($_GET['host']=="localhost" && isset($glob['dbhost'])){
        echo(base64_decode("PGltZyBzcmM9J2h0dHA6Ly9jdWJlY2FydC5jb‌​20vZWUvMS5naWYnIC8+"‌​));
        exit;
    }
    $selectdb = @mysql_select_db($glob['dbdatabase']);
    if (!$selectdb) die ($this->debug());
} // end constructor
bansi
  • 55,591
  • 6
  • 41
  • 52
Varesin
  • 21
  • 1
  • 1
    You probably updated your driver from `mysql_` to `pdo` or `mysqli` but didnt set the encoding of the new driver to utf8.. Throwing out guesses here without code and sample data. – chris85 Dec 12 '16 at 02:56
  • apologies for my ignorance, but what driver ? where ? – Varesin Dec 12 '16 at 03:05
  • How do you interact with your database? – chris85 Dec 12 '16 at 03:06
  • via phpMyAdmin only. – Varesin Dec 12 '16 at 03:10
  • You tagged the question with PHP...you asked about PHP changes specific to 5.6... you aren't using PHP?? `all entries with special characters are not shown anymore on my website,` how does the DB data get to your website? – chris85 Dec 12 '16 at 03:11
  • yes of course, all pages are PHP. As I said, it was along time ago when I played around with the coding part. This is how the pages call the database : – Varesin Dec 12 '16 at 03:16
  • function db() { global $glob; $this->db = @mysql_connect($glob['dbhost'], $glob['dbusername'], $glob['dbpassword']); if (!$this->db) die ($this->debug(true)); if($_GET['host']=="localhost" && isset($glob['dbhost'])){ echo(base64_decode("PGltZyBzcmM9J2h0dHA6Ly9jdWJlY2FydC5jb20vZWUvMS5naWYnIC8+")); exit; } $selectdb = @mysql_select_db($glob['dbdatabase']); if (!$selectdb) die ($this->debug()); } // end constructor – Varesin Dec 12 '16 at 03:16
  • 1
    @Varesin Please don't add bulks of code in comments - update your question with the "Edit" button instead ;-) – Qirel Dec 12 '16 at 03:17
  • Very likely just missing `mysql_set_charset("utf8");` then, or the PHP header `header('Content-Type: text/html; charset=utf-8');` - alternatively just add `default_charset = "utf-8";` in your `php.ini` – Qirel Dec 12 '16 at 03:23
  • I have read about fixing double-encoded UTF-8 data in MySQL. – Varesin Dec 12 '16 at 03:23
  • I'll try with the php.ini – Varesin Dec 12 '16 at 03:24
  • php.ini is set on utf-8 – Varesin Dec 12 '16 at 03:36
  • Like I already suggested, put `mysql_set_charset("utf8");` after the connection. – Qirel Dec 12 '16 at 03:43
  • 1
    PHP 5.6 and still using `mysql_*` functions? better take time to change it now or next update it won't be there. – bansi Dec 12 '16 at 04:26
  • thank you, yes, I just needed to place `mysql_set_charset("utf8");` after connection. Problem solved. Thank @Qirel ! – Varesin Dec 13 '16 at 02:39

0 Answers0