Phpmyadmin - error for symbol ° - mysql

I seem to have a weird problem with my Phpmyadmin database. When I use the symbol ° in my table subject it gives an error and won't insert, for my table message however this doesn't make a difference.
I tried it as a VARCHAR and as TEXT, but both give errors. The message field is a TEXT and doesn't give any errors.
I found this: http://fogbugz.stackexchange.com/questions/2156/how-do-i-fix-incorrect-string-value-x-errors-when-running-on-mysql
My outputs are: utf8_general_ci, latin1_swedish_ci, latin1_swedish_ci
Error:
DB Error #1366
INSERT INTO table SET created=NOW() ,ticketID=7403, subject='FW: Stackoverflow N� 456'
Incorrect string value: 'xB0 4100...' for column 'subject' at row 1

Change Collation of your table to utf8_general_ci

I was able to get it to work with a patch supplied by the vendor of my program.

Related

Incorrect string value: '\xC3' for column

I can't save some data in my mysql database.
SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xC3' for column 'title' at row 1
row title use the collation utf8mb4_unicode_ci.
What's wrong with it? How could I save my data?
PS: I try pretty much every solution give in stackoverflow. That why I create a new thread.
C3 may indicate a utf8 character being interpreted as latin1. Or it may indicate "double encoding".
SHOW VARIABLES LIKE 'char%';
See... utf8
The solution is probably to connect with utf8mb4, not with the default.
What version of MySQL are you using? What parameters does Doctrine use when connecting?
Am getting the same error while I try to upload (🗽<- this type [UTF8]). '1366. Incorrect string value: '\xF0\x9F\x98\x80' for column'
But am changing the data type to 'mediumblob' then its working fine.
check out the screenshot. Now the error solved

Getting Incorrect string value: '\x92\xB7\xFF\xF3' while using AES_ENCRYPT in MySQL

I know and I've researched a lot of very similar problems in Stackoverflow. I've tried all solutions and nothing has worked to me.
I've used following query to insert user records
INSERT INTO `user`(user_name,`password`) VALUE ("D001",AES_ENCRYPT('password1234',"hello"))
When I do this, I'm getting
1 row(s) affected, 1 warning(s)
Execution Time : 00:00:00:046
Transfer Time : 00:00:00:000
Total Time : 00:00:00:046
Warning Code : 1366
Incorrect string value: '\x92\xB7\xFF\xF3\xD1\xF6...' for column 'password' at row 1
---------------------------------------------------
with the above updation, row is getting inserted with just user_user but password is empty.
What I've done by referring similar problems are as follows
1) SET NAMES utf8mb4
2) ALTER TABLE user CONVERT TO CHARACTER SET utf8mb4;
3) Inside my.ini configuration file, I've added character_set_server=utf8mb4
Still I'm getting the same problem. How to resolve this?
UPDATE:
Problem is not specific to just password. What I wanted to do to scramble all required columns so that users can't see those columns normally.
So, I've used AES_ENCRYPT.
The issue is that you are storing binary data in a char,varchar or text column.
Either
store your data as hex:
INSERT INTO user(user_name,password) VALUE ("D001",HEX(AES_ENCRYPT('password1234',"hello")))
And use the UNHEX() function when you need to decrypt it; AES_DECRYPT(UNHEX(password),"hello")
Or
convert your password column to a type that can store binary data, such as the binary or varbinary type.

Invalid unicode character causing MySQL string error

I need to add a record to our MySQL database (via Omeka) that includes an invalid unicode character (this one)
The error message I get via Omeka is:
Mysqli statement execute error : Incorrect string value: '\xF0\xAA\xA8\xA7\xE7\x94...' for column 'text' at row 1
The database field is longtext with collation utf8_unicode_ci. There are already a lot of records in this table and I'm not quite sure what I should change without affecting the other data already in it. Suggestions?
ALTER TABLE tbl CONVERT TO utf8mb4;
Meanwhile, the text for that row in that column is probably truncated or the whole row is missing.
As best as I can tell, F0AAA8A7 is not yet assigned, but I think it is in the area of Chinese characters, not Emoji, which also need utf8mb4. It is Unicode "codepoint" 2AA27.

Incorrect string value: '\xC1\xA4\xBB\xF3'

I'm working with a Korean payment gateway and one of the responses from the bank comes back like this:
Á¤»ó
When trying to insert that value into MySQL database, I get an error:
Incorrect string value: '\xC1\xA4\xBB\xF3'
I have tried changing the collation in that column to utf8mb4_unicode_ci and utf8mb4_general_ci with success.
Here's my 'top' answer:
If you were expecting to see 정상, then we need to talk about euckr, not utf8.
We need to understand where the bytes are coming from, what the CHARACTER SET is on the column in the table (SHOW CREATE TABLE), the client language (Java/PHP/etc), and perhaps more things.

How can I process data to avoid MySQL "incorrect string value" error?

I am trying to use a Rake task to migrate some legacy data from MS Access to MySQL. I'm working on Windows XP, using Ruby 1.8.6.
I have the encoding for Rails set as "utf8" in database.yml.
Also, the default character set for MySQL is utf8.
99% of the data is coming in fine, but every now and then I'll get a column value that gives me a error something like this:
Mysql::Error: Incorrect string value: '\x92 Comm...' for column 'name'
at row 1:
INSERT INTO `organizations` ( [...] )
VALUES('Lawyers’ Committee', [...] )
It looks as though the thing that's giving MySQL trouble is the apostrophe immediately after the "s" in the word "Lawyers".
Here's another one...
Mysql::Error: Incorrect string value: '\x99 aoc' for column 'department'
at row 1:
INSERT INTO `addresses`
[...]
'TRInfo™ aoc'
[....]
Looks like it's choking on the "TM" after "TRInfo".
Is there any Ruby or Rails method that I can run the data through to cleanse from it any characters that MySQL will choke on?
Ideally, it would be great to replace them with more palatable characters -- replace the apostrophe with a single quote and the TM symbol with the string "(TM)".
Or, if I could somehow configure MySQL to store those characters as-is without errors that would be great too.
It looks like your input data is not in utf-8.
I did a little investigating and the styled quote used in Lawyer's is encoded as \x92 in the Windows-1252 encoding, but would be nonsense for utf-8 (when I decoded it and encoded it into utf8, I got \xe2\x80\x99).
Thus you will need to convert the input strings from windows-1252 to utf-8 (or to unicode).
I had the same problem when putting contents of UTF-16 encoded files - which usually store one character per 16bit block - into mysql tables with java. The problem was that the UTF-16 encoded string contained so called surrogate pairs. It means two consecutive 16bit UTF-16 blocks encode one special character but cannot be translated into a corresponding UTF-8 encoding individually. See wikipedia for further explanation.
The solution was to simply replace these characters with spaces. This is the character range you might want to strip out of your string: U+D800–U+DFFF
In general, this happens when you insert strings to columns with incompatible encoding/collation.
I got this error when I had TRIGGERs, which inherit server's collation for some reason.
And mysql's default is (at least on Ubuntu) latin-1 with swedish collation.
Even though I had database and all tables set to UTF-8, I had yet to set my.cnf:
/etc/mysql/my.cnf :
[mysqld]
character-set-server=utf8
default-character-set=utf8
And this must list all triggers with utf8-*:
select TRIGGER_SCHEMA, TRIGGER_NAME, CHARACTER_SET_CLIENT, COLLATION_CONNECTION, DATABASE_COLLATION from information_schema.TRIGGERS
And some of variables listed by this should also have utf-8-* (no latin-1 or other encoding):
show variables like 'char%';
It looks like your old database is in one string format (utf8?) and your rails is expecting something else. If you input is in utf8, have you tried configuring your rails to support it?
I encountered the same problem today.
After tried many times, I found out the reason and fix it at last.
For applications that store data using the default MySQL character set and collation (latin1, latin1_swedish_ci), so you need to specify the character set and collation to utf8/utf8_general_ci when your create your database or table.
e.g.:
$sql = "CREATE TABLE " . $table_name . " (
id mediumint(9) NOT NULL AUTO_INCREMENT,
bookname varchar(128) NOT NULL,
author varchar(64) NOT NULL,
PRIMARY KEY (id),
KEY (bookname)
)CHARACTER SET utf8 COLLATE utf8_general_ci;";
Reference:
《mysql create table problem? SOLVED!!!!!!!!!!!》
http://forums.mysql.com/read.php?121,193883,193883
《10.1.5. Configuring the Character Set and Collation for Applications》
http://dev.mysql.com/doc/refman/5.0/en/charset-applications.html
Hoping this can help you.
Adding binary before the weirdcolumn solves the problem.
In my case, I have an update trigger on tableA to insert data into other table.
There are some special characters in column weirdcolumn, and the update failed with message: "ERROR 1366 (HY000): Incorrect string value: '\xE7....'"
After I dig in a lot, I found the solution by adding binary before the string column name, or using cast(weirdcolumn as binary);
Hope this can help.
I had the same issue importing data from SQL Server to MySql using Php.
My solution was utf8_encode() when inserting into MySql and use utf8_decode() when retrieving from MySql to display into the browser.
Here you have my FULL code, that works good.
//For string values
$Gro2=(is_null($row["GrpNm"]))?"NULL":"\"".mysql_escape_string(utf8_encode($row["GrpNm"]))."\"";
$sqlMy ="INSERT INTO `tbl_name` VALUES ($Gro2)";
Please note: For new projects use
mysqli_escape_string()
link