php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36389 error on binding result parameter for prepared statement
Submitted: 2006-02-14 12:52 UTC Modified: 2006-02-15 10:12 UTC
From: camka at email dot ee Assigned: georg (profile)
Status: Not a bug Package: MySQLi related
PHP Version: 5.1.2 OS: win xp
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: camka at email dot ee
New email:
PHP Version: OS:

 

 [2006-02-14 12:52 UTC] camka at email dot ee
Description:
------------
When trying to bind a result variable to a prepared statement the error "Using unsupported buffer type: 253" comes up.
Moreover, the binded in paramter doesn't get binded correctly either as seen from mysql log.

The other strange thing is that, if field datatype varchar(15) (< then 16) is used for tm table, than error 253 won't come up, buth the problem with binded parameter remains. Integer type works without the error as well.

Tested with both current stable php version and the latest snapshot (Built On: Feb 14, 2006 11:30 GMT)

Reproduce code:
---------------
<?php
echo "PHP version: ".phpversion();
$m = new mysqli('localhost','***','***','***');

$v = $m->query("select @@version as v")->fetch_assoc();
echo "\nMySQL version: ".$v['v'];

$m->query("create temporary table tm (txt varchar(16))");
$m->query("insert into tm (txt) values ('2'),('3'),('4')");


$v = $m->query("select count(*) as v from tm")->fetch_assoc();
echo "\nNum of recs: ".$v['v'];

$str = "select txt from tm where txt=?";
$ps = $m->prepare($str);

$txt_in  = '2';
$txt_out = null;

if (!$ps->bind_param('s', $txt_in)) echo "\nbind_param: ".$ps->error;
if (!$ps->bind_result($txt_out))    echo "\nbind_result: ".$ps->error;
if ($ps->execute())                 echo "\nexecuted successfully: ".$ps->num_rows;
else                                echo "\nfailed ps execution: ".$ps->error;
if (!$ps->store_result())           echo "\nstore_result: ".$ps->error;
if ($z = $ps->fetch())              echo "\nfetched successfully: ".$txt_out;
elseif($z === false)                echo "\nfailed fetching: ".$ps->error;
elseif($z === null)                 echo "\nno more records";
?>

Expected result:
----------------
PHP version: 5.1.2
MySQL version: 5.0.18-nt-log
Num of recs: 3
executed successfully: 0
fetched successfully: 1

Actual result:
--------------
PHP version: 5.1.2
MySQL version: 5.0.18-nt-log
Num of recs: 3
bind_result: Using unsupported buffer type: 253 (parameter: 1)
executed successfully: 0
no more records

[mysql log file]
58 Query       select @@version as v
58 Query       create temporary table tm (txt varchar(16))
58 Query       insert into tm (txt) values ('2'),('3'),('4')
58 Query       select count(*) as v from tm
58 Prepare     [1] 
58 Execute     [1] select txt from tm where txt=0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-14 18:24 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.1-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.1-win32-latest.zip


 [2006-02-14 23:15 UTC] camka at email dot ee
problem remains
 [2006-02-14 23:22 UTC] tony2001@php.net
Georg, please take a look at it.
Looks like another client<->server version incompatibility and/or windows weirdness.
Not reproducible on Linux with MySQL 5.0.16.
 [2006-02-15 08:37 UTC] georg@php.net
Please try latest version from 
http://dev.mysql.com/downloads/connector/php/
 [2006-02-15 09:39 UTC] camka at email dot ee
The latest PHP extension + mysql client API lib from mysql.com solved the problem.

Thanks a lot.
 [2006-02-15 10:12 UTC] tony2001@php.net
Not PHP problem.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue May 24 00:03:50 2022 UTC