Reputation: 663
I migrate to another ISP with my website and I have problem. I ake dump my mySQL database, import in new ISP and when connect from web I have bad signs like: "wy??�?czy?? si�? podczas u??ywania, nie uruchamia si�?,"
I'm from Poland so I use local signs like ę, ą etc. I don't know where is the problem with charset, I don't change this in database. How I can convert this database or another resolve this problem?
function db_connect(){
$connect_support = mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS)
or die('bd server');
mysql_select_db(SQL_DB)
or die('table');
//$charset = mysql_client_encoding($connect_support);
//echo "Charset is: $charset\n";
}
Upvotes: 0
Views: 194
Reputation: 371
change collation
understand utf8 and have a look at: utf8-encode
check the differences between the datatypes you can use.
Upvotes: 0
Reputation:
This is how I ended up solving my problem:
First mysqldump -uusername -ppassword --default-character-set=latin1 database -r dump.sql
Then run this script
$search = array('/latin1/');
$replace = array('utf8');
foreach (range(128, 255) as $dec) {
$search[] = "/\x".dechex($dec)."/";
$replace[] = "&#$dec;";
}
$input = fopen('dump.sql', 'r');
$output = fopen('result.sql', 'w');
while (!feof($input)) {
$line = fgets($input);
$line = preg_replace($search, $replace, $line);
fwrite($output, $line);
}
fclose($input);
fclose($output);
Upvotes: 1