I am trying to do an extremely simple query using mysqli. It is driving me mad!
I just want $data
to be an array of the values from the sql query.
This is my code...
$req = $app->request();
$hashtag = $req->get('hashtag');
require_once 'Slim/lib/database.php';
$db = connect_db();
$statement = $db->prepare("SELECT `content` FROM `posts` WHERE `content` LIKE ?");
$newhashtag = '%#' . $hashtag . '%';
$statement -> bind_param("s", $newhashtag);
$statement -> execute();
$statement -> bind_result($result);
while ( $row = mysqli_fetch_array($statement) ) {
$data[] = $row;
}
print_r($data);
$statement -> close();
I just get an error mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given
and it doesn't make a difference using $result
or $statement
on the fetch_array