php - bind_param giving error "Parameter 3 to mysqli_stmt_bind_param() expected to be a reference" -
i'm trying values of column datetime , using values number of entries made on day. i'm passing array bind_param. here error:
"parameter 3 mysqli_stmt_bind_param() expected reference"
i've tried commented method doesn't seem work either. here's code :
<?php $hostname = "localhost"; $database = "ti_project"; $username = "root"; $password = ""; $mysqli = new mysqli($hostname, $username, $password, $database); $query = "select datetime feedback"; $result = $mysqli->prepare($query); /*$result->bind_param('s', $datetime);*/ $result->execute(); $result->bind_result($date); while ($result->fetch()){ $feedbackdate[] = array($date); } $type="s"; $query = "select count(*) feedback datetime = ?"; $result = $mysqli->prepare($query); call_user_func_array('mysqli_stmt_bind_param', array_merge (array($result, $type),$feedbackdate)); $result->execute(); /*$ref = new reflectionclass('mysqli_stmt'); $method = $ref->getmethod("bind_param"); $method->invokeargs($result,$feedbackdate); $result->execute(); *$result->bind_*result($count);*/ while ($result->fetch()){ $count[] = array( 'count' => $count ); } echo json_encode($count); $result->close(); $mysqli->close(); ?>
missing statement variable in function call. function accepts 3 parameters , not 2. missing provide prepared statement.
call_user_func_array('mysqli_stmt_bind_param', $stmt, array_merge (array($result, $type), $feedbackdate));
please read mysqli_stmt_bind_param function reference here
Comments
Post a Comment