ID: 31037 Comment by: cythrawll at cythnet 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 reproduced this (on accident) with php 5.1.2 on MySQL 4.1.14 Slackware 10.2 Client version: 40114 Server version: 40114 Previous Comments: ------------------------------------------------------------------------ [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/ ------------------------------------------------------------------------ [2006-02-13 01:03:14] mczub at newcomo dot pl This script (with 1 variable): ------------------------------ <?php $mysql = new mysqli("localhost", "***", "***", "test"); printf("Client version: %s\n", $mysql->client_version); printf("Server version: %s\n", $mysql->server_version); $mysql->query("DROP TABLE IF EXISTS temp_table"); $mysql->query("CREATE TABLE temp_table(username varchar(20), user_id int)"); $mysql->query("INSERT INTO temp_table VALUES ('foo', 1)"); if ($stmt = $mysql->prepare("SELECT username FROM temp_table WHERE user_id = ?")) { $stmt->bind_param('i', $user_id); $user_id = 1; $stmt->execute(); $stmt->bind_result($name); $stmt->fetch(); printf("Name: %s\n", $name); $stmt->close(); } $mysql->close(); ?> Output: ------- Client version: 40107 Server version: 50018 Name: This script (with 2 variables): ------------------------------ <?php $mysql = new mysqli("localhost", "***", "***", "test"); printf("Client version: %s\n", $mysql->client_version); printf("Server version: %s\n", $mysql->server_version); $mysql->query("DROP TABLE IF EXISTS temp_table"); $mysql->query("CREATE TABLE temp_table(username varchar(20), user_id int, user_id2 int)"); $mysql->query("INSERT INTO temp_table VALUES ('foo', 1, 2)"); if ($stmt = $mysql->prepare("SELECT username FROM temp_table WHERE user_id = ? AND user_id2 = ?")) { $stmt->bind_param('ii', $user_id, $user_id2); $user_id = 1; $user_id2 = 2; $stmt->execute(); $stmt->bind_result($name); $stmt->fetch(); printf("Name: %s\n", $name); $stmt->close(); } $mysql->close(); ?> Output: ------- Client version: 40107 Server version: 50018 Warning: mysqli_stmt::bind_param() [function.bind-param]: Number of variables doesn't match number of parameters in prepared statement in C:\wamp\www\learn\mysql.php on line 12 Name: It's weird... ------------------------------------------------------------------------ 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