I have a problem, im working on a script and it was all going fine until suddenly it takes the main page 1.2 min to load, after A LOT of commenting and uncommenting i found out the following function was making everything slow:
function toFollow(){
$sql = "SELECT id FROM tofollow WHERE enabled = '1'";
if (!$result = mysql_query($sql)) {
return 'A error occured: ' . mysql_error();
}
while ($row = mysql_fetch_assoc($result)) {
$users[] = $row['id'];
}
return $users;
}
UPDATE:
I found out what the problem was, on the same script i run:
foreach(toFollow() as $user){
$connection->post('friendships/destroy', array('user_id' => $user));
$count++;
}
So, I just changed it to:
$tofollow = toFollow();
foreach($tofollow as $user){
$connection->post('friendships/destroy', array('user_id' => $user));
$count++;
}
And it works!! (I still dont understand what the problem was)
Thanks everyone!!
Any suggestions?