Bug #53171 [NEW]: Problem with accented characterers
| From: | kesler dot alwin at gmail dot com | Date: | Tue, 26 Oct 2010 15:44:31 +0000 |
| Subject: | Bug #53171 [NEW]: Problem with accented characterers | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-155538@lists.php.net to get a copy of this message | ||
From:
Operating system: Windows XP
PHP version: 5.2SVN-2010-10-26 (snap)
Package: MySQL related
Bug Type: Bug
Bug description:Problem with accented characterers
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 bug report at http://bugs.php.net/bug.php?id=53171&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53171&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53171&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53171&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=53171&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53171&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=53171&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=53171&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=53171&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=53171&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=53171&r=support
Expected behavior: http://bugs.php.net/fix.php?id=53171&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=53171&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=53171&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=53171&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53171&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53171&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=53171&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=53171&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=53171&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=53171&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=53171&r=mysqlcfg