MySQL Forums
Forum List  »  PHP

Re: 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 02, 2006 05:02AM

Ok, there were some other libs on my system:

1. I have DB Designer installed which has a small lib - renamed with extension .backup
2. I also had a copy of PHP 5.1.1, which I removed just to be sure
3. Of course there is a dll in the MySQL bin directory - renamed

Now I just have one libmysql.dll in the windows/system32 dir and one corresponding php_mysqli.dll in the php/ext dir. I've restarted Apache but it still complains with the same warning message.

My config:

- Windows XP Pro
- PHP 5.1.2
- MySQL server 5.0.18
- latest mysqli client api libs from dev.mysql.com

Now... I tried to isolate the things I'm doing in a smaller script:

$oMysql = new mysqli('localhost', '...', '...', '...');

$id_1 = 1;
$stmt = $oMysql->stmt_init();
$stmt->prepare("SELECT * FROM my_table1 WHERE id_1=?");
$stmt->bind_param("i", $id_1);
$stmt->execute();
$stmt->store_result();
printf("query 1: %d rows selected.<br>", $stmt->num_rows);

$id_2 = 1;
$stmt = $oMysql->stmt_init();
$stmt->prepare("SELECT * FROM my_table2 WHERE id_2=?");
$stmt->bind_param("i", $id_2);
$stmt->execute();
$stmt->store_result();
printf("query 2: %d rows selected.<br>", $stmt->num_rows);

...And this works nicely. The real queries are a bit more complicated then these ones, but I've checked them in a SQL client and they're working as expected.

I also noted that the bind_param warning message will appear when using the wrong names, for example if id_1 would not exist. This is a bit confusing: one would expect another type of message. However, my queries are correct.

Anyway, the fact that this code snippet works kinda proves that you CAN do multiple statements on one mysqli connection, right? So I'm kinda lost as to why this is not working in the application I'm developing... What else could be the case?

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.