ID:               38753
 Updated by:       [EMAIL PROTECTED]
 Reported By:      tigreverde at hotmail dot com
-Status:           Open
+Status:           Bogus
-Bug Type:         Performance problem
+Bug Type:         MySQLi related
 Operating System: XP
 PHP Version:      5.1.6
 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.




Previous Comments:
------------------------------------------------------------------------

[2006-09-08 19:21:14] tigreverde at hotmail dot com

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 this bug report at http://bugs.php.net/?id=38753&edit=1

Reply via email to