0
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;
}
}
對於它的工作原理,並將其添加到數據庫中的第一項,但之後,它提供了以下錯誤: 試圖讓非對象無法訪問PHP數組MySQL查詢
print_r的財產( $水庫)提供了以下的輸出:
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
)
我只是想存儲的ID數據庫
'print_r($ res)'的後期值; – Saty
通過print_r($ array_name)顯示數組; –
注意:'mysql_ *'函數已被棄用,它們已從PHP 7中移除,當您升級到該版本時,您的代碼將停止工作。您不應使用它們編寫新代碼,而應使用['mysqli_ *'或PDO](http://php.net/manual/en/mysqlinfo.api.choosing.php)。 –