Bug #53171 [Fbk->NoF]: Problem with accented characterers

From: Date: Mon, 18 Feb 2013 00:34:33 +0000
Subject: Bug #53171 [Fbk->NoF]: Problem with accented characterers
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-176927@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=53171&edit=1

 ID:               53171
 Updated by:       php-bugs@lists.php.net
 Reported by:      kesler dot alwin at gmail dot com
 Summary:          Problem with accented characterers
-Status:           Feedback
+Status:           No Feedback
 Type:             Bug
 Package:          MySQL related
 Operating System: Windows XP
 PHP Version:      5.2SVN-2010-10-26 (snap)

 New Comment:

No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


Previous Comments:
------------------------------------------------------------------------
[2010-12-20 14:23:44] andrey@php.net

Do you get this also with 5.3?

------------------------------------------------------------------------
[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 https://bugs.php.net/bug.php?id=53171&edit=1


Thread (3 messages)

« previous php.bugs (#176927) next »