Use $sql_query_posts = substr($sql_query_posts, 0, -1);
like this:
$sql_query_posts .= " IN (";
while ( $row_form_permissions = mysql_fetch_assoc($sql_form_permissions) ) {
$sql_query_posts .= $row_form_permissions['form_id'] . ",";
}
$sql_query_posts = substr($sql_query_posts, 0, -1);
$sql_query_posts .= ")";
Just to address the case when you might end up with no records fetched (an empty array), it would maybe be wiser to use implode(), like this (I always use it like that):
$ins = array();
while ( $row_form_permissions = mysql_fetch_assoc($sql_form_permissions) ) {
$ins[] = $row_form_permissions['form_id'];
}
$sql_query_posts .= sprintf(' IN (%s)', implode(',', $ins));