Hello am trying to update a column in my sql database using values from a foreach loop but am getting..Invalid argument supplied for foreach()
foreach($ids as $id){
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://api.twitter.com/1/
users/lookup.json?user_id=".$id."");
curl_setopt($ch, CURLOPT_HEADER, 0);
// grab URL and pass it to the browser
$contents = curl_exec ($ch);
$ok=array();
$ok=json_decode($contents,true);
foreach($ok['results'] as $p){
$location=$p['location'];
$query=mysql_query("UPDATE tweets SET location=".$location."
WHERE from_user_id=".$id."");
if($query){
print'ok';
}else{print'sds';}
}
// close cURL resource, and free up system resources
curl_close($ch);
}
What am i doing wrong?
cheers people!!!!
foreachand do aprint_r($ok['results']);I don't think that it is a valid array.foreach()loop and put theprint_r($ok['results']);directly thejson_decode()