Why insert in database value date as: شهريور
?
How can search this word in database(شهريور)?
In database: structure => date => varchar(255) => utf8_general_ci = "شهريور".
Why insert in database value date as: شهريور
?
How can search this word in database(شهريور)?
In database: structure => date => varchar(255) => utf8_general_ci = "شهريور".
You website uses an encoding in which these characters do not exists, so the browser sends HTML entities instead.
(Try this here: http://codepad.viper-7.com/dfFMvW ; This page is in ISO-8859-1, if you send non-ISO-8859-1 characters in the input, they are sent as HTML entities.)
To avoid this you have to use a different encoding, like UTF-8.
Add this header in your <head>
tag:
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
Or do this in your PHP before printing anything:
header('Content-Type: text/html; charset=UTF-8');
And make sure your database uses UTF-8 too.
You can convert your database to UTF-8 by doing this:
ALTER DATABASE your_database CHARACTER SET utf8;
-- for each table:
ALTER TABLE some_table CONVERT TO CHARACTER SET utf8;
And after you connect to the database, send this query:
SET NAMES UTF8;
You dont need to html escape those characters as long as you have a UTF* table, and you do.
Simply make sure that the table is UTF8, that the connection is utf8, and the browser reads the texts as utf8.
SET CHARACTER SET
, SET NAMES
, SET COLLATION_CONNECTION
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type" />
and the according http headers, if needed