Since you are inserting into multiple table try using transactions also. Also you cannot get the mysql_insert_id() before the query gets executed.
mysqli_autocommit($link, FALSE);
$sql = "INSERT INTO posts (titel, post) VALUES ('".$titel."', '".$post."')";
if (mysqli_query($link, $sql ) === TRUE) {
$postId = mysqli_insert_id($link);
$sql1 = "INSERT INTO post_categories (idposts) VALUES ('".$postId."')";
mysqli_query($link, $sql1 );
}
if (!mysqli_commit($link)) { //commit transaction
print("Table saving failed");
exit();
}