From:             tigreverde at hotmail dot com
Operating system: XP
PHP version:      5.1.6
PHP Bug Type:     Performance problem
Bug description:  function is not working as described

Description:
------------
The code is supposed to able insert two values into a table, but it is not
doing so.  There is something wrong between prepared stmt and
mysql_stmt_bind_param.

Reproduce code:
---------------
<?php

// Make the connection.
$dbc = @mysqli_connect ('localhost', 'root', 'platypus', 'test') OR die
('Could not connect to MySQL: ' . mysqli_connect_error() );

// Make the query.
$query = "INSERT INTO accounts (name, balance) VALUES (?, ?)";

// Prepare the statement.
$stmt = mysqli_prepare($dbc, $query);

// Bind the variables.
mysqli_stmt_bind_param($stmt, 'sd', $name, $balance);

// Create an array of values to be inserted.
$data = array(
        array('Italo Calvino', 65465.99),
        array('Vladimir Nabokov', 132.74),
        array('James Joyce', 432.74),
        array('William Faulkner', 841664.67),
        array('F. Scott Fitzgerald', 69.23),
        array('Zora Neale Hurston', 130654.44),
        array('Franz Kafka', 87.63),
        array('William Carlos Williams', 9.98),
        array('Jane Austen', 1324.02),
        array('George Eliot', 49683.56)
);

// Print a caption.
echo "<p>The query being prepared is: $query</p>\n";

// Loop through the array, inserting each record.
foreach ($data as $record) {

        // Assign the variables.
        $name = $record[0];
        $balance = $record[1];
        
        // Execute the query.
        mysqli_stmt_execute($stmt);
        
        // Print the results.
        echo "<p>Name: $name<br />Balance: $balance<br />Result: ";
        // Print a message based upon the result.
        if (mysqli_stmt_affected_rows($stmt) == 1) {
                echo 'OK';
        } else {
                echo 'FAILED ' . mysqli_stmt_error($stmt);
        }
        
        echo '</p>';
        
} // End of foreach loop.


Expected result:
----------------
Name: Italo Calvino
Balance: 65465.99
Result: OK

Actual result:
--------------
Warning: mysqli_stmt_bind_param() [function.mysqli-stmt-bind-param]:
Number of variables doesn't match number of parameters in prepared
statement in c:\program files\apache group\Apache\htdocs\Ch11\prepared.php
on line 21
The query being prepared is: INSERT INTO accounts (name, balance) VALUES
(?, ?)
Name: Italo Calvino
Balance: 65465.99
Result: FAILED No data supplied for parameters in prepared statement


-- 
Edit bug report at http://bugs.php.net/?id=38753&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=38753&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=38753&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=38753&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=38753&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=38753&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=38753&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=38753&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=38753&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=38753&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=38753&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=38753&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=38753&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=38753&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=38753&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=38753&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=38753&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=38753&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=38753&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=38753&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=38753&r=mysqlcfg

Reply via email to