Restoring issues - encoding error (UTF-8)

Post your support requests/solutions for phpMySQLAutoBackup [website]
davidgwalker
MODS thats what I do that is! But definately NO mod music! It has to be ROCK!
Posts: 1809
Joined: Mon Oct 25, 2004 8:20 pm
Location: Huddersfield, UK
Contact:

Restoring issues - encoding error (UTF-8)

Postby davidgwalker » Fri Jul 30, 2010 8:47 am

I have received several emails regarding problems restoring from backups.

In many cases it is the encoding you may be using, such as UTF-8 encoding (http://www.utf8.com/)

Christian Thompson suggested this simple solution:
    Add the following lines after the mysql_connect() statement:

    mysql_query("SET session character_set_results = 'UTF8'");
    mysql_query("SET session character_set_client = 'UTF8'");
    mysql_query("SET session character_set_connection = 'UTF8'");
    mysql_query("SET session character_set_results = 'UTF8'");
    mysql_query("SET session character_set_server = 'UTF8'");

    As you can guess this gets the system "thinking" in UTF8. Also, I made sure
    the .php script files were encoded in UTF8.

Also when creating the tables you should specify the encoding like this:
CREATE DATABASE dbName DEFAULT CHARACTER SET utf8;

And use the statement "SET NAMES 'utf8'" EACH TIME you connect to mysql
(via the command-line or from PHP scripts - as above).
There is also more details here:
http://forums.mysql.com/read.php?103,66007,66007
(also search the MySQL forum for other posts)

Hope that helps anyone with similar issues.

Dave
ps. Want to add/modify anything to above then please contact me: http://www.dwalker.co.uk/contact.php

Return to “phpMySQLAutoBackup [forum]”

Who is online

Users browsing this forum: No registered users and 2 guests