I have a website hosted on a GoDaddy (Shared Windows server) which I wrote some time ago using procedural PHP and a MySQL database. Some tables in the database hold data that is inserted by users through some pages and in some cases they insert Greek text. Everything was working fine for the last 3-4 years until recently when I was informed that the website was down for some reason. I contacted GoDaddy, they told me that it must be an issue with my scripts but I have not made any changes to the code for a long time now. Anyway, apparently it was resolved the same day without me doing anything so I guess it was an issue with their servers, although they told me that nothing was changed from their side.
The problem is that since then, all the pages which display Greek characters selected from the database show them like this: Άλλο Αίτημα instead of proper Greek text. I know that they were stored like that in the database (when I access it with phpMyAdmin) but I thought this was normal until now because when they were selected and displayed in the pages they were fine. So I don't know what has happened now and they stopped appearing correctly. By the way, Greek characters (not from the database) are displayed correctly in the pages. I've searched the internet a lot about this and I have tried all possible solutions, I believe. Some things I have checked (copied from another SO answer):
- All PHP files are saved as UTF-8 encoding (without BOM, using Notepad++)
- MySQL database, tables and columns are all set to utf8_unicode_ci
- PHP's default character set is UTF-8
I use the following code in my header file:
header('Content-Type: text/html; charset=utf-8');
and then in html head:
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
I use the following code to connect to the database in my db connection file:
$dbc = mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error() );
mysqli_set_charset($dbc, 'utf8');
The server is running PHP version 5.2.17 and MySQL version is 5.0.96.
Another weird thing is that when I export the database and import it locally (using XAMPP) and using the same PHP files as on the website, Greek characters are displayed correctly on the pages. However, XAMPP on my laptop is running PHP version 5.4.7 and MySQL is version 5.5.27.
Any suggestions would be greatly appreciated.
Thanks