|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-12-20 14:23 UTC] andrey@php.net
-Status: Open
+Status: Feedback
[2010-12-20 14:23 UTC] andrey@php.net
[2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 15:00:01 2025 UTC |
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 áéíóú') .")"