how to update database from get user_timeline twitter multiple rows using php mysql -


i'm trying create database table filled in twitter api, facebook api, , instagram api.

this tried

  foreach($string $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 , 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 case dont know how update multiple rows without id using social media type update didn't work.

this displaying function updatesocmed:

function updatesocmed($type, $updatedata){     $update = array();     array_walk($updatedata, 'array_sanitize');      foreach($updatedata $fields => $data){         $update[] = '`' . $fields . '` = \'' . $data .'\'';         }         mysql_query("update `socmed` set" . implode(', ',$update) . "where `socmed_type` =  '$type'") or die(mysql_error());     } 

please help..

you missed single quote ' $type in condition

mysql_query("update `sosmed` set" . implode(', ',$update) . "where `socmed_type` =  '$type'") or die(mysql_error()); 

note: mysql_query deprecated in php 5.5.0, , removed in php 7.0.0. instead, mysqli or pdo_mysql extension should used.alternatives function include: mysqli_query() or pdo::query()


Comments