I'm trying to get an array of x amount of data using PreparedStatements and fetch_assoc(). It doesn't return anything. Here's the code:
if(isset($query_published) && isset($query_date) && isset($query_sort) && isset($query_rows)){
//Does meet the requirements
$stmt = $db -> prepare("SELECT source, title, timeadded, tags, filed, added, priority, timepublished
FROM news_archive WHERE ? AND ? ORDER BY ? LIMIT ?");
$stmt -> bind_param('sssi', $query_date, $query_published, $query_sort, $query_rows);
//is valid, It's String, String, String, and an Integer.
$stmt -> execute();
$result = $stmt -> get_result();
while($row = $result -> fetch_assoc()){
//Doesn't run this loop at all.
$return .= "<tr>";
$return .= "<td>" . $row["source"] . "</td>";
$return .= "<td>" . $row["title"] . "</td>";
$return .= "<td>" . $row["timeadded"] . "</td>";
$return .= "<td>" . $row["timepublished"] . "</td>";
$return .= "<td>" . $row["filed"] . "</td>";
$return .= "</tr>";
}
$db -> close();
}
I've verified it's not a MySQL problem, since I can run regular queries just fine. I tried printing out the parameters such as $query_date, $query_published, $query_sort, $query_rows
before execution, and they are legitimate values.
The query is fine too. I filled the question marks with the parameters, and ran it on MySQL, is a valid query.