[英]how to update database from get user_timeline twitter multiple rows using php mysql
i'm trying to create database with a table filled in twitter api, facebook api, and instagram api. 我正在尝试使用填充了Twitter api,facebook api和instagram api的表创建数据库。
this is what i tried 这就是我尝试过的
foreach($string as $items)
{
$date = new DateTime($items['created_at']);
for($id=1;$id<=5;$id++){
echo $id;
}
$socmed = array(
'socmed_id' => $id,
'socmed_type' => 'twitter',
'socmed_time' => $date->format('Y-m-d H:i:s'),
'socmed_caption' => $items['text']);
echo $socmed['socmed_id'];
echo "Time and Date of Tweet: ".$socmed['socmed_time']."<br />";
echo "Tweet: ". $socmed['socmed_caption']."<br />";
echo "Screen name: ". $socmed['socmed_type']."<br /><hr />";
updateSocmed($socmed['socmed_type'],$socmed);
}
in this case i dont know how to update multiple rows without id so i using social media type to update all but it didn't work. 在这种情况下,我不知道如何更新没有ID的多行,因此我使用社交媒体类型来更新所有内容,但没有用。
this is displaying my function updateSocmed: 这显示了我的功能updateSocmed:
function updateSocmed($type, $updateData){
$update = array();
array_walk($updateData, 'array_sanitize');
foreach($updateData as $fields => $data){
$update[] = '`' . $fields . '` = \'' . $data .'\'';
}
mysql_query("UPDATE `socmed` SET" . implode(', ',$update) . "WHERE `socmed_type` = '$type'") or die(mysql_error());
}
please help.. 请帮忙..
You are missed single quote '
for $type in where condition 您在以下情况下错过了单引号
'
for $ type
mysql_query("UPDATE `sosmed` SET" . implode(', ',$update) . "WHERE `socmed_type` = '$type'") or die(mysql_error());
Note: mysql_query was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. 注意:mysql_query在PHP 5.5.0中已弃用,在PHP 7.0.0中已删除。 Instead, the MySQLi or PDO_MySQL extension should be used.Alternatives to this function include: mysqli_query() or PDO::query()
而是应使用MySQLi或PDO_MySQL扩展名。此函数的替代方法包括: mysqli_query()或PDO :: query()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.