I'm trying to get the values of a column dateTime and then using those values get the number of entries made on that day. So I'm passing an array to bind_param. But here I get the error:
"Parameter 3 to mysqli_stmt_bind_param() expected to be a reference"
I've also tried the commented method which doesn't seem to work either. Here's the code :
<?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();
?>