foreach($res as $key) {
echo $key['id'].'<br>';
$sql= "INSERT INTO Post VALUES('".$key['id']."')";
if (mysql_query($sql) == TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $link->error;
}
}
For the first entry it works and adds it to the database but after that it gives the following error : Trying to get property of non-object
print_r($res) gives the following output :
Array
(
[0] => Array
(
[message] =>*******
[created_time] => DateTime Object
(
[date] => 2016-01-13 20:14:32.000000
[timezone_type] => 1
[timezone] => +00:00
)
[id] => 1413366785545501_1686416964907147
)
[1] => Array
(
[message] =>*****
[created_time] => DateTime Object
(
[date] => 2015-11-27 15:51:16.000000
[timezone_type] => 1
[timezone] => +00:00
)
[id] => 1413366785545501_1674032329478944
)
[2] => Array
(
[message] => The 'AD- MAD' competition :)
[story] => KRITA // Chalk your art. added 4 new photos.
[created_time] => DateTime Object
(
[date] => 2015-10-07 19:02:12.000000
[timezone_type] => 1
[timezone] => +00:00
)
[id] => 1413366785545501_1662706990611478
)
[3] => Array
(
[message] => *****
[story] => KRITA // Chalk your art. created a poll.
[created_time] => DateTime Object
(
[date] => 2015-10-02 21:06:05.000000
[timezone_type] => 1
[timezone] => +00:00
)
[id] => 1413366785545501_1661659277382916
)
I just want to store the id's in the database