Req #54605 [Opn]: promote the usage of mysql_set_charset

From: Date: Fri, 04 May 2012 09:27:47 +0000
Subject: Req #54605 [Opn]: promote the usage of mysql_set_charset
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-8339@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: uw@php.net Reported by: tyra3l at gmail dot com Summary: promote the usage of mysql_set_charset Status: Open Type: Feature/Change Request Package: Documentation problem PHP Version: Irrelevant -Assigned To: +Assigned To: philip Block user comment: N Private report: N New Comment: Do you think this can be closed meanwhile? Previous Comments: ------------------------------------------------------------------------ [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

« previous php.doc.bugs (#8339) next »