Non-English Characters - 1366: Incorrect string value: '\xF9

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
stoneferry
Forum Newbie
Posts: 9
Joined: Sat Feb 16, 2008 10:39 am

Non-English Characters - 1366: Incorrect string value: '\xF9

Post by stoneferry »

Hello, having some trouble with a PHP script and trying to update or insert into MYSQL database where non-English characters are concerned.

From what I found so far for example, ù and à or any other non-English character result in error in my script (i.e. I've tried them by themselves only):

1366: Incorrect string value: '\xF9'


I can go into the MySQL Workbench and insert ú and these characters fine without this error. Having done that when I try to read it this character becomes 'úA'


What am I doing wrong?

I've tried "mysql_set_charset('utf8');" before executing my query.

Database schema is set to UTF8-Default Collation

Thanks
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: Non-English Characters - 1366: Incorrect string value: '

Post by Apollo »

You are not using utf-8 everywhere. 0xF9 by itself is not a valid utf-8 encoded character, to begin with.

Try this:

Code: Select all

mysql_query('SET NAMES UTF8; SET character_set_server = UTF8;');
Also, when you say the character becomes 'úA', how/where do you mean? How are you verifying this result? If you're outputting it on a test page, does the page specify utf-8 encoding in its http ot html header?
stoneferry
Forum Newbie
Posts: 9
Joined: Sat Feb 16, 2008 10:39 am

Re: Non-English Characters - 1366: Incorrect string value: '

Post by stoneferry »

Hi thanks the response. Both problems resolved.

The error with the 1366 Incorrect string was due to the fact I'm using a HTML Form for an insert and I didn't correctly set it to use UTF8. The below resolved this:

<form accept-charset="utf-8" ...>

The issue where the UTF8 characters were correctly in the database, but then returning back to the form as á é à ó ú etc was because I had not set my headers correctly, resolved per the below:

<?php header("Content-type: text/html; charset=utf-8"); ?>


All of the resolutions were taken from the below article:

http://akrabat.com/php/utf8-php-and-mysql/
Post Reply