"to use utf8 or not - mysql and php character encoding issue" Code Answer
Answers related to “to use utf8 or not - mysql and php character encoding issue”
- The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead
- Setting PHP default encoding to utf-8?
- Convert latin1 characters on a UTF8 table into UTF8
- MySQL and PHP - insert NULL rather than empty string
- ucfirst() function for multibyte character encodings
- PHP generated XML shows invalid Char value 27 message
- Should I use prepared statements for MySQL in PHP PERFORMANCE-WISE?
- PHP mysql charset utf8 problems
- PHP character encoding problems
- Json: PHP to JavaScript safe or not?
- UTF8 Encoding problem - With good examples
- how to use throw exception in mysql database connect
- html_entity_decode - character encoding issue
- How would I get the birthdays of friends who are celebrating their birthday this week, this month and next month...
- PHP htmlentities() not working as expected
- Connecting to a remote database from a localhost computer using mysql and PHP
- How to use bind_result() instead of get_result() in php
- Zend_Cache: After loading cached data, character encoding seems messed up
- Character encoding php mysql
- AES encryption in mysql and php
- PHP and Java hmac hash output matches in hex, doesn't match in raw binary. What's happening?
- Resolving incorrect character encoding when displaying MySQL database results after upgrade to PHP 5.3
- PHP Include and accents (They show up as ?)
- How do I retrieve results as multidimensional array from mySQL and PHP?
- How to convert text with HTML entites and invalid characters to it's UTF-8 equivalent?
- Character Encoding issue with PHP Simple HTML DOM Parser
- Having trouble with Php, Mysql and UTF8
- php XML export issue with XMLWriter using writeAttribute() method
- When to use Redis instead of MySQL for PHP applications?
- Replace diacritic characters with “equivalent” ASCII in PHP?
- How to force XPath to use UTF8?
- Trim whitespace ASCII character “194” from string
- Containerizing Apache, MySQL and PHP With Docker
- TinyMCE UTF-8 saving to MySQL Database
- any way to detect and remove (or fix) bad characters resulting from bad encoding conversions
- How can character encoding be made correctly in both php and mysql database
- PHP mysql turkish character encoding and comparison
- Connecting to eBay Trading API through SoapClient throws 'The web service eBayAPI is not properly configured or not...
- Joomla article page: code to check published or not
- Where do I need to use backticks or quotes in my MYSQL query?
- MySQL charsets and collations: accent insensitive doesn't work
- How to JSON parse images from mysql and populate listview
- Special characters in UTF8 mailto: subject= link and Outlook
- PHP and character encoding problem with  character
- Reading partial json data with MySQL and PHP
- json_encode and persian words?
- Mysql and php fixes to replicate PDO security
- Weird problem with preg_replace and chinese character
- Differentiate between 'no rows were affected' and rows succesfully UPDATEd--to same value (MySQL and PHP)
- How to use line breaks in Flex with PHP string
- PHP + MySQL encoding issues for Portuguese (PT-Br)
- php gzcompress encoding issue
- PHP function ord() returns wrong code of cirilyc charecter
- how to use UTF8 character in path Address for Scandir php
- PHP: Updating with öäå into MySQL
- How to perform batch operation using mysql and php
- How to pass a latin1 charset associative array from php to javascript?
- php mysql - should i add the field “category-name” to a table or not?
- PHP - Convert ?Çô to dash
- Escaping Characters Such as $ and % | MySQL and PHP
- PHP Strange character before £ sign?
- Character Encoding Problem
- How to store escaped characters in MySQL and display them in php?
- How to use 'WHERE' clause using ssp.class.php DataTables
- How to read non-ASCII characters from CLI standard input
- What are the best practices to encrypt passwords stored in MySql using PhP?
- how to use solr with mysql and php?
- AJAX Polling Frequency - To long poll or not to long poll?
- PHP fputcsv encoding
- Which to use: REMOTE_ADDR or SERVER_ADDR
- Select count for each distinct row (mysql and php)
- How to paginate a table of Mysql in PHP
- How do I store correlation values between users in a database using MySQL and PHP?
- cmd's character set
- how to get the position of sorted rows using mysql and php
- To double escape or not to double escape in PHP PCRE functions?
- Is ASCII “../” the only byte sequence that indicates a directory traversal in PHP?
- How to use fsockopen (or compatible) with SOCKS proxies in PHP?
- PHP function iconv character encoding from iso-8859-1 to utf-8
- Character encoding fail, why does \xBD display improperly in PHP + HTML
- To use sleep() or cron job
- Character Encoding UTF8 Issue when using mb_detect_encoding() with PHP
- Transform project from windows-1256 to utf-8 charset, what's the right steps?
- How to use Laravel Eloquent model in core PHP?
- Submitting form, mysql and php
- Is it better to use ob_get_contents() or $text .= 'test';
- How to update multiple columns in mysql using php
- Unique text field in MySQL and php
- Unable to save large text in mysql thru php
- Why is ë percent encoded to %EB but also to %C3%AB?
- Get source code with Chinese characters PHP
- PHP imap_search: UTF-8 / Non-ASCII characters on Microsoft Exchange mail servers
- recording username into table from session with mysql and php
- How can you compare sets of numbers and get the most relevant results using MySQL and PHP?
- utf8 not showing hyphens correctly in echoed text
- Turkish character encoding with MySQL
- PHP's var_dump / print_r output is garbled - encoding issue?
- php page not displaying arabic text
- How to process array element into MySQL with PHP?
- How to insert a record in MySQL with PHP with an HTML form
- how to check null or not if mysql datatype is timestamp with a default value of “0000-00-00 00:00”?
- String Comparison using PHP mysql_* SET NAMES UTF 8 and Mysql Table With utf8_unicode_ci
- MySQL and PHP Unexpected T_Variable
- How to use array variable into mysql query in php/mysql
- How to set the charset to UTF-8 for a received http variable in PHP?
- PHP decode GB2312
- how to join two tables on common attributes in mysql and php?
- fql query character encoding
- MySQL collation and PHP charset conflict
- updaing sql table using UPDATE mysql and php syntax
- Mysql and PHP LIKE query generates no results on page but returns result in Mysql
- iconv() – how to detect offending character?
- MySQL and PHP Select Option with information from database
- When to use single quotes, double quotes, and backticks in MySQL
- Setting the default Java character encoding
- What is character encoding and why should I bother with it
- MySQL and PHP: UTF-8 with Cyrillic characters
- What is the difference between utf8mb4 and utf8 charsets in MySQL?
- strange character encoding of stored data , old script is showing them fine new one doesn't
- MySQL stored procedures use them or not to use them
- How to detect the character encoding of a text file?
- jQuery AJAX Character Encoding
- How to use objects from other namespaces and how to import namespaces in PHP
- PDO + MySQL and broken UTF-8 encoding
- SQL Server default character encoding
- How do I correct the character encoding of a file?
- UTF-8 character encoding battles json_encode()
- How to use special characters in recipients name when using PHP's mail function
- JDBC character encoding
- how to use DISTINCT ON with mysql using ActiveRecord
- Stored Procedures, MySQL and PHP
- To use self. or not.. in Rails
- What is the character encoding of String in Java?
- Chart.js - Getting data from database using mysql and php
- JDBC url for MySQL configuration to use utf8 character encoding
- How do I set Character Encoding to UTF-8 for default.html?
- Default Javascript Character Encoding?
- GCC 4.7 Source Character Encoding and Execution Character Encoding For String Literals?
- Character Encoding issue in Rails v3/Ruby 1.9.2
- How do I change a shell scripts character encoding?
- Character encoding issue exporting rails data to CSV
- Set request character encoding of JSF input submitted values to UTF-8
- UTF-8 not working in HTML forms
- What's the character encoding used? [closed]
- Java Spring resttemplate character encoding
- How does “cut and paste” affect character encoding and what can go wrong?
- Is there a Python library function which attempts to guess the character-encoding of some bytes?
- Eclipse character encoding
- request.getParameter() does not display properly character encoding in java servlet
- When to use datetime or timestamp
- How to convert HTML entities like – to their character equivalents?
- Does HTML5 specify a default character encoding for HTML documents if no character encoding is supplied?
- Where do I set character encoding in SOAPUI Preferences
- How to read a file in Java with specific character encoding?
- utf 8 - PHP and MySQLi UTF8
- Using utf8mb4 in MySQL
- System.out character encoding
- Encoding issue with Axios
- Is there a way to use UTF-8 with app engine?
- preg_match and (non-English) Latin characters?
- Grails request parameters encoding issue in Tomcat
- Spring MVC response encoding issue
- Windows Phone character-encoding
- How to make cascading drop-down lists using mysql and php
- Is there any way to check whether or not the query inside a MySQL trigger returns an empty set?
- Embedded C++ : to use exceptions or not?
- What is the difference between iconv() and mb_convert_encoding() in PHP?
- To use goto or not?
- JavaScript function to convert UTF8 string between fullwidth and halfwidth forms
- How to declare character encoding in an INDIVIDUAL JS file?
- How does GHC/Haskell decide what character encoding it's going to decode/encode from/to?
- Character Encoding Issue - Strange Behaviour From Pound Signs (£) with UTF-8 IE6 / ASP / XML
- Encoding issue, coverting & to & for html using php
- Detecting character encoding in HTML
- Getting special characters out of a MySQL database with PHP
- Simple html dom character encoding issue
- How to parse a string that is in a different encoding from java
- Dartlang with polymer character encoding
- Character encoding in query string, hebrew
- To which character encoding (Unicode version) set does a char object correspond?
- How to change Column Collation without losing or changing data?
- PHP - Fast way to strip all characters not displayable in browser from utf8 string
- Fix Turkish Charset Issue Html / PHP (iconv?)
- Character encoding in python to replace 'u2019' with '
- Convert a MySQL database from latin to UTF-8
- Mysql: Set column charset
- Why is table CHARSET set to utf8mb4 and COLLATION to utf8mb4_unicode_520_ci
- CRUD for MySQL and PHP [closed]
- How to convert mysql latin1 to utf8
- Command line character encoding from PHP's exec()
- Searching for availability with MySQL (and PHP)?
- when initializing PDO - should I do: charset=UTF8 or charset=UTF8MB4?
- UTF-16 Character Encoding of java
- Strings and character encoding in C++
- React + Webpack character encoding issues
- To use getAttribute(), or not to use getAttribute(): that is the question
- How does the platform default character encoding affect cross platform performance
- UTF-8 MySQL and Charset
- Character encoding issues on websphere
- Arabic text output php mysql utf-8 conversion issue
- Cannot store UTF8 characters in MySQL
- Still necessary to use 'Status: 404 Not Found' for FCGI?
- Laravel 5 route pagination url encoding issue
- mysql replace accented characters
- #1115 - Unknown character set: 'utf8mb4'
- How to decode Feedburner result containing \x3c and so on
- Should I use backticks or not when escaping keywords in MySQL?
- Comparing timestamp with date variable (MySQL and PHP)
- Use Single Row Query with MySQL and PHP
- HTML and character encoding vs HTML Entity
- How to use one or more OR and AND in mysql query
- How to use wordwrap or otherwise to break text to fit a fluid-width div
- How to configure spring boot application to use SSL/TLS over MySQL?
- Creating a stored procedure: setting the character set and collation
- Possible to force CMake/MSVC to use UTF-8 encoding for source files without a BOM? C4819
- htmlentities and é (e acute)
- User defined ordering using MySQL and PHP
- How can I convert Cyrillic stored as LATIN1 ( sql ) to true UTF8 Cyrillic with iconv?
- Wrong Unicode conversion, how to store accent characters in Delphi 2010 source code and handle character sets?
- Query a Query - MySQL and PHP
- Character encoding in R
- What is the appropriate character encoding for a git repo?
- Why am I able to use a character that's not part of a charset (windows-1252)?
- Decode obfuscated PHP source code
- Beginner question on mySQL and PHP to avoid connecting to DB on every page
- JSP Not Suppported by UTF-8 Encoding
- character encoding issue with the BCP and ó
- WCF and custom text encoding - messy business
- Special characters get lost in MySQL export/import
- Character encoding issue when using Google Apps Script to extract data from web page
- System.IO.File.ReadAllText not throwing exception for invalid encoding
- What charset to use when reading in a java source file?
- How can I know if url-encoded string is UTF-8 or Latin-1 with PHP?
- spring boot commandline runner is using windows default character encoding
- PostgreSQL encoding issue while executing query from command line
- Encoding issue when handling a string that contains "question mark" (�)
- Mysql bulgarian languages, character set
- How to change “Character Encoding” property of Rational Team Concert
- Making MySQL work with utf-8 in my.cnf configuration file
- When should you use single or double quotes in PHP?
- Charcter encoding and PHP
- Is there any reason not to use UTF-8, 16, etc. for everything?
- Encoding issue when using Nokogiri replace
- Is it possible to "sniff" the Character encoding?
- Chinese character encoding?
- How to retrieve utf-8 data with php and show the correct encoding in an excelsheet db dump?
- Will iso-8859-1 display german umlauts ok or do I need to use utf-8?
- MySQLdb can't initialize character set utf-8 error
- ColdFusion XLS "Export" and Character Encoding
- How to identify character encoding from website?
Only authorized users can answer the Search term. Please sign in first, or register a free account.
your problem is that your
set names 'utf8_persian_ci'
command was invalid (utf8_persion_ci is a collation, not an encoding). if you run it in a terminal you will see an errorunknown character set: 'utf8_persian_ci'
. thus your application, when it stored the data, was using thelatin1
character set. mysql interpreted your input as latin1 characters which it then stored encoded as utf-8. likewise when the data was pulled back out, mysql converted it from utf-8 back to latin1 and (hopefully, most of the time) the original bytes you gave it.in other words, all your data in the database is completely messed up, but it just so happened to work.
to fix this, you need to undo what you did. the most straightforward way is using php:
set names latin1;
set names utf8;
alternatively you can perform these steps inside mysql, but it's tricky because mysql understands the data to be in a certain character set. you need to modify your text columns to a blob type, then modify them back to text types with a utf8 character set. see the section at the bottom of the
alter table
mysql documentation labeled "warning" in red.after you do either one of these things, the bytes stored in your database columns will be the actual character set they claim to be. then, make sure you always use
mysql_set_charset('utf8')
on any database access from php that you may do in the future! otherwise you will mess things up again. (note, do not use a simplemysql_query('set names utf8')
! there are corner cases (such as a reset connection) where this can be reset tolatin1
without your knowledge.mysql_set_charset()
will set the charset whenever necessary.)it would be best if you switched away from
mysql_*
functions and usedpdo
instead with thecharset=utf8
parameter in your pdo dsn.