This question already has answers here:
UTF-8 all the way through
(13 answers)
Closed 3 years ago.
I want to store arabic in mysql database but when I execute query it convert arabic to some numbers like u0645u0631u062du0628u0627
when I print this query in which $datas='hello'
insert into taxi_notification(user_id,message,datetime,type)
values(".$user_id.",'".$datas."',NOW(),'".$type."');
it converts it to
insert into taxi_notification(user_id,message,datetime,type)
values(1965,'\u0645\u0631\u062d\u0628\u0627',NOW(),'admin_notification')
I want to store Arabic string as it display in browser
You must have to change your collation as utf8_general_ci.
Related
This question already has answers here:
UTF-8 all the way through
(13 answers)
Closed 2 years ago.
I'm using Slovenia characters and PHP MySQL select where clause to fetch results from the database. This query is working properly with English letters but has an issue with Slovenia letters like (ć, č, đ, š). I have set database collation to utf8_slovenian_ci. And encoding of php files is utf8
I don't know how Slovenia characters are processed, but try this (it worked with Arabic characters):
$string = "ćčđš";
$mysqlEscaped = mysqli_escape_string($string);
This question already has answers here:
Turn off scientific notation MySQL
(2 answers)
Closed 3 years ago.
I use php to store a very big int in mysql ,the value is 13262075231096090737 ,but I echo that value,it shows as 1.3262075231096E+19, when I store as varchar,it also show as 1.3262075231096E+19. I want to know how to store a very huge int in mysql??
in your database change field type to 'text' instead of 'varchar'
The problem you are experiencing is not to do with the storage of the BIGINT, but rather the displaying of that number in PHP.
See this post for examples using:
number_format()
sprintf()
printf()
Why is PHP printing my number in scientific notation, when I specified it as .000021?
This question already has answers here:
How can I prevent SQL injection in PHP?
(27 answers)
Closed 4 years ago.
I'm trying to insert data into a mysql database, with the code below.
Problem is, my json code containing the value "R\u00f8nde" is changed to "Ru00f8nde" after I insert it into the database.
What is the best way to avoid this?
INSERT INTO jos_payplans_user(user_id, params) VALUES ('24882', '{"modtager":"Anders And","adresse":"Paradisaeblevej 111","postnr":"1234","by":"R\u00f8nde","telefon":"12345678","user_notes":""}')
In json itself avoid the slashes and insert in db
echo json_encode($value, JSON_UNESCAPED_SLASHES);
This question already has answers here:
Save Data in Arabic in MySQL database
(8 answers)
Closed 6 years ago.
I am having problems storing urdu characters in Mysql table. Values from HTML form are stored in tables but when I view in phpmyadmin, it shows weird characters.
I have tried ucs2 and utf8 collations but still new values which I store are unknown characters.
What is the correct collation type? Or is there anything else that is wrong?
Thanks
Try setting your column as utf8-utf8_general_ci like this if you are using MySQL workbench.
Then you will be able to save urdu characters
Recommend using utf8_unicode_ci for accuracy
This question already has answers here:
UTF-8 all the way through
(13 answers)
Closed 6 years ago.
Is there any way to save Bengali Language content in database without encoding, like: আমার will be saved exactly as আমার. But it is inserted as গলà§à¦ªà§‡ গলà§à¦ªà§‡ সি পà§à. it is being coded before save but how could I prevent this automatic encoding?
In this case, I would prefer using urlencode and urldecode. So before it is sent to the DB, I'll use:
urlencode($content); // %E0%A6%86%E0%A6%AE%E0%A6%BE%E0%A6%B0
And while displaying:
echo urldecode($content); // আমার
Output:
https://ideone.com/O8UaTl
https://ideone.com/TBvy1z
This way, it is safe to be stored. But only one issue is, the content's length in URL Encode will be larger than the original one.
But the right way, is to use UTF8-MB4 or similar Encoding in the Database. Eg. in MySQL:
CREATE TABLE `whatever` (
-- Fields
) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;