ballouta Posted October 23, 2008 Share Posted October 23, 2008 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 More sharing options...
realjumper Posted October 23, 2008 Share Posted October 23, 2008 What happens if you do this: <?php $query = "SELECT * FROM `books` order by `ncode` ASC "; $result = mysql_query($query); while( $row = mysql_fetch_array($result) ) { echo "Book: $row[bname]<br>"; } ?> Link to comment https://forums.phpfreaks.com/topic/129804-solved-problem-with-collation/#findComment-673031 Share on other sites More sharing options...
discomatt Posted October 23, 2008 Share Posted October 23, 2008 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 Link to comment https://forums.phpfreaks.com/topic/129804-solved-problem-with-collation/#findComment-673058 Share on other sites More sharing options...
ballouta Posted October 23, 2008 Author Share Posted October 23, 2008 @ 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 Link to comment https://forums.phpfreaks.com/topic/129804-solved-problem-with-collation/#findComment-673112 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.