MySQL Forums
Forum List  »  Full-Text Search

Re: Arabic text in mysql Varchar row
Posted by: Mark Webley
Date: September 11, 2011 08:01AM

Currupted db...interesting...looks like then do a mysql table delete and create it again?

I will try that but first I am wondering could it be that because
my html page is utf8 and then when it inserts the data in the the
database that is set to utf8...on insert could the db be converting
the data again....?




But in the meantime I did tests:

The $title value comes from a submitted webform, with title set to:
<input type="text" value="<? echo utf8_decode(POST[title]) ?>"

HTML tag is:
html xmlns="http://www.w3.org/1999/xhtml"; lang="ar" xml:lang="ar" >


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


The <form> tag element has no:
accept-charset="UTF-8"

when I php echo result from the db to the page I use:
nl2br(utf8_decode($title))


TESTS:
when I changed mysql query to utf8_encode($title) to utf8_decode($title):
database shows:
??? ?? ??? ?? ??? ??

after db insert, php echo shows:
??? ?? ??? ?? ??? ??


When I remove both utf8_encode and utf8_decode from the mysql insert query:
database shows:
?? ?? ???? ??

After db insert, php echo shows:
?? ?? ???? ??

To test for existence of double encoding I did:
utf8_decode(utf8_decode($title))

db and php echo shows: ???? ?? ???? ??

Changed back to utf8_encode($title):
db shows: فÙ? اÙ?خط فÙ?
php echo shows: ف�? ا�?خط ف�?





NEW TESTS:
I just added: this to the form tag:
<form accept-charset="UTF-8">

and removed utf8_decode from the form input tag, which is now set to:
<input type="text" value="<? echo POST[title]; ?>"


using mysql insert after form submit with no utf8_encode and utf8_decode for title I see $title:
database shows:
?? ?? ???? ??

After db insert, php echo shows:
?? ?? ???? ??

using mysql insert after form submit with utf8_encode($title):
database shows:
فÙ? اÙ? ف

After db insert, php echo shows:
ف�? ا�? ف

FOR PHP ECHO TO THE PAGE I changed:
nl2br(utf8_decode($title))

TO:
$title

did db insert without utf8_encode and decode db shows: ? ?? ?? ??
did db insert with utf8_encode I see: Ù? فÙ? اÙ?خط



AFTER ALL OF THIS I will delete the table and create a new one...?

Options: ReplyQuote


Subject
Views
Written By
Posted
15842
September 05, 2011 04:23PM
3934
September 07, 2011 08:01PM
5214
September 08, 2011 04:45PM
3144
September 09, 2011 06:46PM
4877
September 11, 2011 08:03AM
2949
September 12, 2011 11:30AM
3574
September 12, 2011 06:16PM
2734
September 12, 2011 06:17PM
2903
September 13, 2011 09:44PM
3104
September 17, 2011 05:53AM
2682
September 18, 2011 01:45PM
2721
September 19, 2011 04:10PM
2839
September 20, 2011 08:19PM
3211
September 25, 2011 12:09PM
2761
September 28, 2011 09:53PM
2977
September 29, 2011 02:44PM
3698
September 30, 2011 10:14AM
3582
September 10, 2011 03:07PM
Re: Arabic text in mysql Varchar row
4071
September 11, 2011 08:01AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.