Bug #53171 [Opn->Fbk]: Problem with accented characterers
Edit report at http://bugs.php.net/bug.php?id=53171&edit=1
ID: 53171
Updated by: andrey@php.net
Reported by: kesler dot alwin at gmail dot com
Summary: Problem with accented characterers
-Status: Open
+Status: Feedback
Type: Bug
Package: MySQL related
Operating System: Windows XP
PHP Version: 5.2SVN-2010-10-26 (snap)
Block user comment: N
Private report: N
New Comment:
Do you get this also with 5.3?
Previous Comments:
------------------------------------------------------------------------
[2010-10-26 17:44:30] kesler dot alwin at gmail dot com
Description:
------------
When i use mysql_real_escape_string() with mysql_set_charset() forcing
to use 'latin1' the accented characters dissapear from the insert
string.
SHOW VARIABLES LIKE 'character_set%';
------------------------------------
character_set_client latin1
character_set_connection latin1
character_set_database latin1
character_set_filesystem binary
character_set_results latin1
character_set_server latin1
character_set_system utf8
PHP info
--------
PHP API 20041225
PHP Extension 20060613
Zend Extension 220060519
I realize that if i comment the mysql_set_charset() command i have no
problems. anyway, if i try to get the connection character (with or
without this command) i'll always get 'latin1', but i just think that
this commando shouldn't cause problems.. till today i have it trying to
stabilize my framework environment
Test script:
---------------
# From the very beginning i disable the magic quotes if it's set
ini_set('magic_quotes_gpc', 0);
# I create a connection like this
$link = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS);
mysql_select_db(SQL_INSTANCE, $link);
# Use the "forced" character set for the connection
mysql_set_charset('latin1', $link);
# In my code i have a class that performs all validation according to
the type of content i'm specting... in this case string's validation
Class vaccine
{
public static function forString($value)
{
if($value == null || $value == 'null')
return 'NULL';
return strlen($value)
? '\''. mysql_real_escape_string($value) .'\''
: 'NULL';
}
}
# then if i'm going to insert in db
$query = "INSERT INTO TABLE VALUES(". Vaccine::forString('this text has
accents from here áéÃóú') .")"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53171&edit=1
Thread (3 messages)