added a way to stop php from working if error encountered