ID: 31037
Comment by: aman dot tur at gmail dot com
Reported By: php at trafex dot nl
Status: No Feedback
Bug Type: MySQLi related
Operating System: Fedora core 1
PHP Version: 5CVS-2005-04-26
Assigned To: georg
New Comment:
I am using WAMP 5 (MySQL 5.0.21 Client 40107, Apache 2 , Windows Server
2003). When i try to execute followint script i get error: Number of
variables doesn't match number of parameters in prepared statement
<?php
$capital=1;
$mysqli=new mysqli('192.168.0.1','root','*','world');
//INIT statement
$stmt=$mysqli->stmt_init();
if (mysqli_connect_errno())
{
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
//Create statement for Procedure
$stmt=$mysqli->stmt_init();
if(!$stmt)
{
printf("Error creating Statement: $s\n",$mysqli->error);
exit();
}
$stmt=$mysqli->prepare("Select name from country where Capital =
?");
if(!$stmt)
{
printf("Error creating Statement: %s\n",$mysqli->errno);
printf("Error creating Statement: %s\n",$mysqli->error);
printf("Statement Error: %s\n",$stmt->error);
exit();
}
printf("No of Parameters in Statement: %d
\n",$stmt->param_count);
printf("Client version: %s\n", $mysqli->client_version);
printf("Server version: %s\n", $mysqli->server_version);
//Bind the paremeter values that are to be passed to stored
procedure
//This line gives error
$stmt->bind_param("i",$capital);
//execute the stored procedure
$stmt->execute();
$stmt->bind_result($name);
$stmt->fetch();
printf("Country Name: %s\n", $name);
$stmt->close();
$mysqli->close();
?>
Previous Comments:
------------------------------------------------------------------------
[2006-04-28 06:33:57] cythrawll at cythnet dot com
I reproduced this (on accident) with php 5.1.2 on MySQL 4.1.14
Slackware 10.2
Client version: 40114 Server version: 40114
------------------------------------------------------------------------
[2006-03-30 20:56:32] droppse at wjh dot harvard dot edu
Updating the mysql client lib's resolved this problem on XP Pro, WAMP.
------------------------------------------------------------------------
[2006-03-28 13:05:55] putu dot dondo at gmail dot com
i get this error too!
i use WAMP5 on windowsXP
------------------------------------------------------------------------
[2006-02-14 01:28:07] skotch at online dot stack dot net
After a couple of nights I've found the solution. Upgrading to newest
versions of PHP and MySQL don't solve the problem.Both PHP and MySQL
have a lib named libmysql but those libs are not the same. Make PHP to
use php/libmysql and everythig will be OK. For ensure the result just
rename the libmysql library from MySQL install and execute your php
script correct!
------------------------------------------------------------------------
[2006-02-13 07:09:06] [EMAIL PROTECTED]
> Client version: 40107 Server version: 50018
Why don't upgrade your client version?
Recompile your PHP extensions or download an actual version from
http://dev.mysql.com/downloads/connector/php/
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/31037
--
Edit this bug report at http://bugs.php.net/?id=31037&edit=1