changing column encoding mysql to appear as arabic language - php

i have table in data base and there is a column have strange language like below '20795, '1818300', '33018964', '1022251015', 'Completed without ID number',
'ÔÇÑÚ ÇáãÑÛäì - ÇáÚãÇÑå ÈåÇ ãÍá ÓÇãÓæäÌ - ÈÌæÇÑ ÚãÇÑå ÇÈæÛÇáì - ÇáÏæÑ ÇáÓÇÈÚ-ÇáãÇÙå-ÇáÞÇåÑå'
but it was inserted as an arabic language using PHPRunner program .
my question is how to update that column to seen as arabic language in mysql .
i need to fix the old data .
note : values appeared normally on arabic language on the webpage
my problem how to change it in DB ,.
note : the format of this table , column is UTF8

You may easily set utf8 to your tables if you are using SQLYog.
Just right click on db, table, column name and click on alter option and set to
Database Chartset = utf8 Database Collation = utf8_general_ci .
Just Enjoy ....

Related

searching for Persian string in MySQL using laravel elequent

In my laravel in order to search in products title column I use the following code:
$products->where('title', 'like', '%' . $request->title . '%');
the title column is a string column and data stored in it are in Persian. Also, the database collation is UTF8_general_ci. however, when I search something some titles are found and some aren't. I need the result to find every product which contains the $request->title in their title columns.
can you help me?
Change Collation UTF8_general_ci to latin1_swedish_ci
Collations have these general characteristics:
Two different character sets cannot have the same collation.
Each character set has one collation that is the default collation. For example, the default collation for latin1 is latin1_swedish_ci. The output for SHOW CHARACTER SET indicates which collation is the default for each displayed character set.
There is a convention for collation names: They start with the name of the character set with which they are associated, they usually include a language name, and they end with _ci (case insensitive), _cs (case sensitive), or _bin (binary).
In cases where a character set has multiple collations, it might not be clear which collation is most suitable for a given application. To avoid choosing the wrong collation, it can be helpful to perform some comparisons with representative data values to make sure that a given collation sorts values the way you expect.
reference here

How to insert special character like £ with price like (£ 2,000) in mysql database

I am unable to insert record to my database table with having data like (£ 2,000).
Can anyone help me with this ?
Thanks
Try encoding the table as:
ALTER TABLE <table_name> CONVERT TO
CHARACTER SET utf8
COLLATE utf8_general_ci;
And make sure the datatype of the column is varchar.
Also if you plan to output that data in a webpage you can to insert HTML Entities for Currencies in the db and then when you output it in a webpage, the HTML will render the entities as regular characters.
It works for me
It seems that changing the column type and collation type did this.I have changed the column type to varchar and collation to utf-8 and it worked.

Enconding problems with MySQL Database (web2project)

When I want to add the name of the project in Russian, the application saves the filled data in non-readable format into mysql database likeпроект номер три де фшоыÑшфыво шщфыовÑшщыв (проект номер три де фшоысшфыво шщфыовсшщыв) . But when i want to see the details about the current project, the view form of the project shows the data as its typed (e.g. проект номер три де фшоысшфыво шщфыовсшщыв).
Since the database is filled with non-utf8 format, the print view of project has the same inconveniences.
What should i change or delete so the inserting process of the data will be in proper way ?
Ð¿Ñ€Ð¾ÐµÐºÑ is Mojibake for проек.
This is the classic case of
The bytes you have in the client are correctly encoded in utf8 (good).
You connected with SET NAMES latin1 (or set_charset('latin1') or ...), probably by default. (It should have been utf8.)
The column in the tables may or may not have been CHARACTER SET utf8, but it should have been that.
If you need to fix for the data it takes a "2-step ALTER", something like
ALTER TABLE Tbl MODIFY COLUMN col VARBINARY(...) ...;
ALTER TABLE Tbl MODIFY COLUMN col VARCHAR(...) ... CHARACTER SET utf8 ...;
where the lengths are big enough and the other "..." have whatever else (NOT NULL, etc) was already on the column.

Issue with charset and data

I try to explain the whole problem with my poor english:
I use to save data from my application (encoded on utf8) to database using the default connection of PHP (latin1) to the tables of my DB with latin1 as charset.
That wasn't a big problem : for example the string Magnüs was stored as Magnüs, and when I recovered the data I saw correctly the string Magnüs (because the default connection, latin1).
Now, I change the connection, using the correct charset, with mysql_query("SET NAMES 'utf8'", $mydb), and I've also changed the charset of my tables's fields, so the value now is correctly store as Magnüs on DB; Then I still seeing Magnüs when I retrieve the data and I print on my Web Application.
Of course, unfortunatly, some old values now are badly printed (Magnüs is printed as Magnüs).
What I'd like to do is "to convert" these old values with the real encoding.
ALTER TABLE <table_name> CONVERT TO CHARACTER SET utf8; will convert only the field type, not the data.
So, a solution (discovered on internet) should be this:
ALTER TABLE table CHANGE field field BLOB;
ALTER TABLE table CHANGE field field VARCHAR(255) CHARACTER SET utf8;
But these old string won't change on database, so neither in the Web Application when I print them.
Why? And what can I do?
Make sure that your forms are sending UTF-8 encoded text, and that the text in your table is also UTF-8 encoded.
According to the MySQL reference, the last two ALTER you mentioned do not change the column contents encoding, its more like a "reinterpretation" of the contents.
Warning
The CONVERT TO operation converts column values between the character sets. This is not what you want if you have a column in one character set (like latin1) but the stored values actually use some other, incompatible character set (like utf8). In this case, you have to do the following for each such column:
ALTER TABLE t1 CHANGE c1 c1 BLOB;
ALTER TABLE t1 CHANGE c1 c1 TEXT CHARACTER SET utf8;
The reason this works is that there is no conversion when you convert to or from BLOB columns.

How to know the actual codification of a text stored in a MySQL table field?

I have a very simple question. I just need to determine the codification (UTF8, latin1) of a text stored in a MYSQL table field.
I've used SELECT COLLATION(column) FROM table LIMIT 1;
Well, the data will be stored according to the charset and collation settings that were in effect at the time the data was stored.
Which charset and collation values are used for a given piece of data can come from any one of four places
Server Settings
Database Settings
Table Settings
Column Settings
All this information is discoverable through querying the INFORMATION_SCHEMA database

Categories