Exclude Categorys from posts loop

I have multiple categories and i want to exclude 2 of them. My problem comes when I go to the next page of posts. All of the following lines will exclude the categories but only on the first page of post results.

when i use the following line my ‘next page’ link go no where, it goes to the same page i click from.

<?php query_posts(‘cat=-17,-36’); ?>

when i use the following line my ‘next page’ link go no where, it goes to the same page i click from. using home.php

<?php if ( is_home() ) {query_posts(‘cat=-17,-36’); } ?>

when i use the following line my ‘next page’ link goes to the next page but the categories are not excluded.