0
我想獲得一個列dateTime的值,然後使用這些值得到當天作出的條目數。所以我傳遞一個數組給bind_param。但在這裏我得到的錯誤:bind_param給出錯誤「參數3到mysqli_stmt_bind_param()有望成爲一個參考」
"Parameter 3 to mysqli_stmt_bind_param() expected to be a reference"
我也試過了似乎不工作的評論方法。這裏是代碼:
<?php
$hostname = "localhost";
$database = "ti_project";
$username = "root";
$password = "";
$mysqli = new mysqli($hostname, $username, $password, $database);
$query = "SELECT dateTime FROM 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(*) FROM feedback WHERE 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();
?>
[mysqli的綁定\ _Param()預期爲基準,給定值(的可能的複製http://stackoverflow.com/questions/16120822/mysqli -bind-param-expected-to-be-a-reference-value-given) –