Edit report at http://bugs.php.net/bug.php?id=31037&edit=1

 ID:                 31037
 Comment by:         noadress at noadress dot com
 Reported by:        php at trafex dot nl
 Summary:            MySQLi - bind_param
 Status:             No Feedback
 Type:               Bug
 Package:            MySQLi related
 Operating System:   Fedora core 1
 PHP Version:        5CVS-2005-04-26
 Assigned To:        georg
 Block user comment: N
 Private report:     N

 New Comment:

I've had the same problem.. and my libs were new.



I had: 

$sqlquery = "UPDATE $table SET title='?', msg='?', date='?' WHERE
ID='?'";

.......

$stmt->bind_param('sssi', $_SESSION['tit'], $_SESSION['tex'],
$_SESSION['dat'], 

$_SESSION['id']); 



--> ERROR - Number of variables doesn't match number of parameters in
prepared 

statement





--> SOLVE

Remove the '' before and after the ?

-> "UPDATE $table SET title=?, msg=?, date=? WHERE ID=?"

and now he did the update ;)



have fun


Previous Comments:
------------------------------------------------------------------------
[2007-11-28 15:51:28] catalin dot tanasescu at filipnet dot ro

I know this is old but ...I had the same problem.

resolved it by adding after each    $stmt->execute(); this

   $stmt->store_result();



very strange ...

hope this helps someone

------------------------------------------------------------------------
[2006-09-11 15:21:16] xpertindia at yahoo dot com

oops correction - 



I got it workig as follows -



$vsql1 = "select userid, email from re_users u where email = ? and

password = ?";



$preparedstatement1 = $gvdblink->prepare($vsql1);

$preparedstatement1->bind_param('ss', $bv1, $bv2);



It is funny that when I put an * (asterix) I get a  warning/error. It
is

sad that we have to specify every column we need to retreive.



This fails -



$vsql1 = "select * from re_users u where email = ? and password = ?";

------------------------------------------------------------------------
[2006-09-11 15:19:16] xpertindia at yahoo dot com

I got it workig as follows -



$vsql1 = "select userid, email from re_users u where email = ? and
password = ?";



$preparedstatement1 = $gvdblink->prepare($vsql1);

mysqli_stmt_bind_param($preparedstatement1, "ss", $bv1, $bv2)



It is funny that when I put an * (asterix) I get a  warning/error. It is
sad that we have to specify every column we need to retreive.



This fails -



$vsql1 = "select * from re_users u where email = ? and password = ?";

------------------------------------------------------------------------
[2006-05-16 07:36:01] aman dot tur at gmail dot com

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();

?>

------------------------------------------------------------------------
[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

------------------------------------------------------------------------


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/bug.php?id=31037


-- 
Edit this bug report at http://bugs.php.net/bug.php?id=31037&edit=1

Reply via email to