this is the problem. a zero is a false value and the code is performing the header redirect.
as to why it 'worked' before, something was probably preventing the header() from working (output being sent, which would have been producing a php error, should you have been able to display/log it) but since there's no exit/die statement after the redirect, the rest of the code on the page still ran in this case, so, you got the expected output for a zero value.
something probably changed in the server configuration, such as php's output_buffing setting getting turned on, which would now buffer whatever the output is, allowing the header() to work.
i wonder if your login access check code has exit/die statements after redirects to stop the rest of the code on the page from being executed?
you should also not put any external data directly into sql queries, where any sql special characters can break the sql query syntax, which is how sql injection is accomplished.