Here is a code how I push image into database:
$title = $_REQUEST['title'];
$description = $_REQUEST['description'];
$image = $_REQUEST['image'];
$bdata = addslashes($image);
$query = "insert into Images (title, description, image) values ($title, $description, '$bdata')" or die("Error in the consult.." . mysqli_error($connection));
$result = $connection->query($query);
$connection->close();
I double checked in database and it stores successfully.
Here is a code which gets data from the table:
$query = "select * from Images" or die("Error in the consult.." . mysqli_error($connection));
$result = $connection->query($query);
$events = array();
while ($event = $result->fetch_array(MYSQLI_ASSOC)) {
$events[] = $event;
}
header('Content-type: application/json');
echo json_encode($events);
$result->free();
$connection->close();
As result I receive next json:
{
id: "34",
title: "some image",
description: "some description",
image: null
}
As you can see "image" field is null. In phpAdmin I see that there is a data.