#42902 [Opn->Csd]: can't call mysqli->set_charset() after mysql_init()
| From: | scottmac@php.net | Date: | Tue, 09 Oct 2007 16:57:25 +0000 |
| Subject: | #42902 [Opn->Csd]: can't call mysqli->set_charset() after mysql_init() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-118330@lists.php.net to get a copy of this message | ||
ID: 42902
Updated by: scottmac@php.net
Reported By: carsten_sttgt at gmx dot de
-Status: Open
+Status: Closed
Bug Type: MySQLi related
Operating System: Windows_NT
PHP Version: 5.2.4
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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