Jump to content

[SOLVED] Problem with Collation


ballouta

Recommended Posts

Hi,

I am trying to read a column 'bname' from table 'books', this column has the collation (utf8_unicode_ci), then insert this column info into another table to same field name and same collation

but the inserted info are garbage and corrcupted (اجابة الداعي الى بيان اعتقا...)

my code

<?php
$query = "SELECT * FROM `books` order by `ncode` ASC ";
$result = mysql_query($query);
while( $row = mysql_fetch_array($result) )
{
$result2 = mysql_query("INSERT INTO `stats` (`ncode` ,`bname` ,`num` )VALUES ('$row[ncode]', '$row[bname]', 0)");
echo "Book: $row[bname] was inserted <br>";
}
?>

 

Please help

 

thank you

Link to comment
https://forums.phpfreaks.com/topic/129804-solved-problem-with-collation/
Share on other sites

Is your PHP page encoded in UTF-8? Have you declared it in the meta?

 

Try doing this immediately after mysql_connect()

 

mysql_query( "SET NAMES 'utf8';" );

 

This might also help

http://www.shawnolson.net/a/946/unicode-data-with-php-5-and-mysql-41.html

 

@ realjumper:

The output is correct because i already have this in the head:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta http-equiv="Content-Language" content="ar-lb">

 

and this link in PHP:

<?php
mysql_query("SET CHARACTER_SET_RESULTS=NULL");
?>

 

@discomatt: Thank you very much, this link solved the problem for me, the second table was filled with readable info (arabic characters)

 

Thank You ALL

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.