简体   繁体   中英

stored procedure prepared statement bug mysql php

Here's my stored procedure:

DELIMITER $$

CREATE DEFINER=`root`@`localhost` PROCEDURE `testProc`(IN num INT, INOUT num2 INT(11))
BEGIN
    set num2 = num+num2+7;
END

Here's the code that calls it:

if ($stmt = mysqli_prepare($con, 'call testProc(?,?)')) {
    mysqli_stmt_bind_param($stmt, 'ii', $type, $newId);
    mysqli_stmt_execute($stmt);
    echo $newId;
    exit;
    }

This is the error I get:

<b>Warning</b>:  mysqli_stmt_execute(): Premature end of data (mysqlnd_wireprotocol.c:1116) in

I don't understand. How can something so simple fail? I was just trying to work out how to get a value back from a prepared statement with a stored procedure when I ran up against this brick wall while trying to set up a simple example. Please help, because until I can solve this I can't provide an example so I can't get my real problem solved. Thanks.

I think you should be using bind_result after bind_param.

Check out http://php.net/manual/en/mysqli-stmt.bind-result.php

and a previous stack overflow question: mysqli bind_param() fatal error

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM