I'm trying to parse a json file and push fields to database jSON Source : http://graph.facebook.com/10153575791993298/
Parsing and Echo
<?php
$json_file = file_get_contents('http://graph.facebook.com/10153575791993298/');
$info = json_decode($json_file);
if ($info) {
foreach ($info->likes->data as $obj){
echo $obj->id, "<br/>";
echo $obj->name, "<br/>";
}
}
?>
Database part :
<?php
// Create connection
$mysqli = new mysqli('localhost', 'root', 'root', 'facebook');
$query = <<<SQL
INSERT INTO Likes ('ID', 'Name')
VALUES (?, ?)
SQL;
$stmt = $mysqli->prepare($query);
foreach ($info['data'] as $key => $value) {
$stmt->bind_param(
// the types of the data we are about to insert: s = string, i = int
'ss',
$value['id'],
$value['name'],
);
$stmt->execute();
}
$stmt->close();
$mysqli->close();
?>
I setup my tables correctly and I don't know why I can't push data to my database.
Json part that I would like to retrieve data and push to my db http://graph.facebook.com/10153575791993298/likes