ID: 41227
Comment by: judas dot iscariote at gmail dot com
Reported By: php_debugger at yahoo dot com
Status: Open
Bug Type: MySQL related
Operating System: Windows XP
PHP Version: 5.2.1
New Comment:
You should use mysqli and the mysqli_set_charset() function.
Previous Comments:
------------------------------------------------------------------------
[2007-04-29 18:16:04] php_debugger at yahoo dot com
Description:
------------
I have met this "bug" while I was creating a Russian site. I have a web
form(ENCODING:UTF-8) and a simple query(My db uses UTF-8). When I submit
the form, I get an error which says that the string is too long for the
column but it is not the case(I just type the letters).
After a while debugging I have found out what is the problem. When I
use mysql_real_escape_string() I get the error else I do not.
I have searched in the php site but I found nothing which has to do
with encoding.
Reproduce code:
---------------
//I will give only the php code though it is very simple
<?php
//MySQL connections and other stuff like this has been omitted because
//of the code's size
$name = mysql_real_escape_string($_POST['name']);
mysql_query("insert into users set name='".$name."');
?>
Expected result:
----------------
No errors.
Actual result:
--------------
MySQL error which says that the string is too long.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41227&edit=1