MySQL Forums
Forum List  »  PHP

Warning: mysqli_stmt::bind_param() [function.bind-param]: Number of variables doesn't match number of parameters in prepared statement in...
Posted by: Bas van Gaalen
Date: April 01, 2006 10:59AM

I get this error message:

Warning: mysqli_stmt::bind_param() [function.bind-param]: Number of variables doesn't match number of parameters in prepared statement in...

When I try to run the following piece of code:

$id = 1;
$oConnection = Db::getInstance()->getConnection());
$stmt = $oConnection->stmt_init();
$stmt->prepare("SELECT * FROM mytable WHERE id=?");
$stmt->bind_param("i", $id); // this line is where the error occurs

The used Db class is a Singleton wrapper for MySQL Improved, which ensures that only one connection is used throughout a script run. At this point in the code, there have been other statements executed on the connection, which work fine. This particular piece of code is executed in a loop that retreives the results of another query, so I cannot re-use the statement and reset it.

(Note: Of course the outter query - not shown - could be optimized and include this query, but that doesn't take away the fact that I'm getting this error message on something that should work.)

I'm using PHP 5.1.2 en MySQL Server 5.0.18 and have tried both PHP native libmysql.dll and php_mysqli.dll files, as well as the ones provided by MySQL (http://dev.mysql.com/downloads/connector/php/) but both fail. Also I have tried to do a search on google for a sollution and the tips provided in the bug report on http://bugs.php.net/bug.php?id=31037. Nothing works...

I cannot find a sollution for this anywhere on the net. What gives??? Please help...

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.