i have a problem i cant solved for cople of hours!
this is the function:
function show_posts($user_id,$limit=0){
$posts = array();
$user_string = implode(',', $user_id);
$extra = " and id in ($user_string) ";
if ($limit > 0){
$extra = "limit $limit";
}else{
$extra = '';
}
$sql = "SELECT userid, caption, stamp, filename FROM photographs
WHERE userid in ($user_string) order by stamp desc $extra";
//echo $sql;
$result = mysql_query($sql) or die(mysql_error())
;
while($data = mysql_fetch_object($result)){
$posts[] = array( 'stamp' => $data->stamp,
'userid' => $data->userid,
'caption' => $data->caption,
'filename' => $data->filename,
);
}
return $posts;
}
and thats the full error:
Warning: implode() [function.implode]: Invalid arguments passed in C:\wamp\www\includes\functions.php on line 12
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') order by stamp desc' at line 2
and the intresting thing that if i echo the sql i get a working one i checked it in phpmyadmin + it shows what it need to show in the index.php if i comment the "or die(mysql_error()) "
here the sql when its do echo
SELECT userid, caption, stamp, filename FROM photographs WHERE userid in (4,7,2) order by stamp desc limit 5
so y the hell this problem is keep coming?
i really cant understand what wrong! :-\
tnx for the help!