Req #54605 [Asn->Csd]: promote the usage of mysql_set_charset
| From: | philip@php.net | Date: | Fri, 08 Jun 2012 00:12:11 +0000 |
| Subject: | Req #54605 [Asn->Csd]: promote the usage of mysql_set_charset | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-8436@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=54605&edit=1
ID: 54605
Updated by: philip@php.net
Reported by: tyra3l at gmail dot com
Summary: promote the usage of mysql_set_charset
-Status: Assigned
+Status: Closed
Type: Feature/Change Request
Package: Documentation problem
PHP Version: Irrelevant
Assigned To: philip
Block user comment: N
Private report: N
New Comment:
This has been fixed in SVN, thank you for the report.
Previous Comments:
------------------------------------------------------------------------
[2012-06-08 00:11:43] philip@php.net
Automatic comment from SVN on behalf of philip
Revision: http://svn.php.net/viewvc/?view=revision&revision=326022
Log: Documented that setting the character set via an SQL query will not be
useful to real_escape_string. This closes PHP Bug #54605
------------------------------------------------------------------------
[2012-05-04 11:17:04] jpauli@php.net
+1 for the exact same reasons as my developers do SET NAMES and are not aware of
such functionality
------------------------------------------------------------------------
[2012-05-04 09:27:47] uw@php.net
Do you think this can be closed meanwhile?
------------------------------------------------------------------------
[2011-04-26 11:26:15] tyra3l at gmail dot com
Description:
------------
I noticed that nobody from my fellow php developers are aware that they should
use mysql_set_charset over mysql_query('SET NAMES utf-8');
I wanted to tell them to RTFM, but currently, the only place that we talk about
mysql_set_charset is on the documentation page of mysql_client_encoding and the
documentation page of that function, which tells that:
"This is the preferred way to change the charset. Using mysql_query() to execute
SET NAMES .. is not recommended."
but doesn't mention why is that.
I would propose adding something like this to the documentation either as a note
or in the description:
"As mysql_real_escape_string takes into account the current character set of the
connection, you should only change client encoding through mysql_set_charset,
not via mysql_query('SET NAMES ...'); or mysql_real_escape_string cannot
guarantee that the string is properly escaped."
maybe we should link http://shiflett.org/blog/2006/jan/addslashes-versus-mysql-
real-escape-string also.
I would also propose that we link mysql_set_charset in the documentation of
mysql_real_escape_string, and adding a mysql_set_charset into every mysql
example.
the same should be done to the mysqli documentation also
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=54605&edit=1