Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql turns ' into ’?

How can I stop mysql from converting ' into ’ when I do an insert?

i believe it has something to do with charset or something?

I am using php to do the mysql_insert.

like image 578
Hailwood Avatar asked Oct 04 '10 10:10

Hailwood


People also ask

What does â € translate to?

For example, ’ evidently represents the apostrophe character; – appears to represent the hyphen character.

How do I change MySQL encoding to UTF-8?

To change the character set encoding to UTF-8 for the database itself, type the following command at the mysql> prompt. Replace dbname with the database name: Copy ALTER DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci; To exit the mysql program, type \q at the mysql> prompt.

Why does É become Ã?

This typically) happens when you're not decoding the text in the right encoding format (probably UTF-8).

Which characters are not allowed in MySQL?

ASCII NUL (U+0000) and supplementary characters (U+10000 and higher) are not permitted in quoted or unquoted identifiers. Identifiers may begin with a digit but unless quoted may not consist solely of digits. Database, table, and column names cannot end with space characters.


1 Answers

The single quotation mark you posted is called an 'acute accent', which is often converted from the generic single quotation mark by some web applications. It's a UTF8 character, which when inserted into a Latin-1 database translates to '’'. This means that you need to change MySQL's charset to UTF8, or alternatively change your website's charset to Latin-1. The former would be preferred:

ALTER DATABASE YourDatabase CHARACTER SET utf8;
ALTER TABLE YourTableOne CONVERT TO CHARACTER SET utf8;
ALTER TABLE YourTableTwo CONVERT TO CHARACTER SET utf8;
...
ALTER TABLE YourTableN CONVERT TO CHARACTER SET utf8;
like image 61
Ashley Williams Avatar answered Sep 20 '22 06:09

Ashley Williams