ID:               42902
 User updated by:  carsten_sttgt at gmx dot de
 Reported By:      carsten_sttgt at gmx dot de
 Status:           Closed
 Bug Type:         MySQLi related
 Operating System: Windows_NT
 PHP Version:      5.2.4
 New Comment:

Hello Scott,

thanks, I've made a test with "php5.2-win32-200710092030.zip" and:
| $mysqli = mysqli_init();
| mysqli_options($mysqli, MYSQLI_SET_CHARSET_NAME, 'utf8');
| mysqli_real_connect($mysqli, 'localhost', 'root', '', 'test');
| echo 'Charset is: ', mysqli_character_set_name($mysqli);
is working now like expected :-)

Just to clarify:
| $mysqli = mysqli_init();
| mysqli_set_charset($mysqli, 'utf8');
still does not work.

But I guess that's a documentation problem? In the manual [1] (not only
for mysqli_set_charset) I can read:
| link  Procedural style only: A link identifier
|       returned by mysqli_connect() or mysqli_init()

and this should be:
| link  Procedural style only: A link identifier
|       returned by mysqli_connect() or mysqli_real_connect()

Regards,
Carsten

[1] http://www.php.net/manual/en/function.mysqli-set-charset.php


Previous Comments:
------------------------------------------------------------------------

[2007-10-09 16:57:25] [EMAIL PROTECTED]

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

MYSQLI_SET_CHARSET_NAME was added for PHP 5.3, I've now backported this
to the 5.2 branch.

------------------------------------------------------------------------

[2007-10-09 14:40:26] carsten_sttgt at gmx dot de

Description:
------------
Hello,

mysqli->set_charset() only works after mysqli->real_connect(), but not
after mysql_init().

BTW:
I don't understand, why there is no MYSQLI_SET_CHARSET_NAME for
mysqli->options()? Because that's the correct way, described in the
MySQL C API.

Regards,
Carsten


Reproduce code:
---------------
----- don't works -----
<?php
$mysqli = mysqli_init();

$mysqli->set_charset('utf8');
echo 'Charset is: ', $mysqli->character_set_name();

$mysqli->real_connect('localhost','root','','test');
?>


----- works -----
<?php
$mysqli = mysqli_init();

$mysqli->real_connect('localhost','root','','test');

$mysqli->set_charset('utf8');
echo 'Charset is: ', $mysqli->character_set_name();
?>


Expected result:
----------------
Charset is: utf8

Actual result:
--------------
Warning: mysqli::set_charset() [function.mysqli-set-charset]: invalid
object or resource mysqli in \test.php on line 4
Charset is:
Warning: mysqli::character_set_name()
[function.mysqli-character-set-name]: invalid object or resource mysqli
in \test.php on line 5


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=42902&edit=1

Reply via email to