Page isn't working ' http error 500' ,

i have a file to get some data of pages, if a page is scanned then status is 1; if pending then status is 0; by a sql query i make a request to server for those links who have status =0 ;

when ever i request for links those have status is 0 it return http 500 error , if i request for links with status 1 it works without a problem .