PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » MDB2_Driver_mysqli » Bug #8807

Parameter order is wrong in fallback code in setCharset()

Details

Submitted2006-09-28 12:17 UTC
Fromfredrik at wangel dot net
Assignedlsmith
StatusClosed
PackageMDB2_Driver_mysqli
PHP VersionIrrelevant
Roadmaps(Not assigned)

Comments

[2006-09-28 12:17 UTC] fredrik at wangel dot net

Description:
------------
MDB2_Driver_mysqli::setCharset():
If the mysqli_set_charset() function is missing, the fallback code tries to call mysqli_query() with a query prepared using mysqli_real_escape_string(). However, the order of the parameters to these two functions is incorrect, resulting in PHP warnings.

Test script:
---------------
A patch to fix this bug:

527,528c527,528
< $query = "SET character_set_client = '".mysqli_real_escape_string($charset, $connection)."'";
< $result = @mysqli_query($query, $connection);
---
> $query = "SET character_set_client = '".mysqli_real_escape_string($connection, $charset)."'";
> $result = @mysqli_query($connection, $query);

Expected result:
----------------
No warnings, no errors.

Actual result:
--------------
Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, string given in E:\apache\php\pear\MDB2\Driver\mysqli.php on line 527