The First return value is always zero

Hi guys!

I’ve doing some kind of login system with mysql database.

i do get the correct value if im entering the correct username and password(i checked the value during debugging)
but i just don get it, why the first return value is always zero, and the second return will get the first time value.

I do have some replicated functions involved. maybe i was wrong

what i want to do:
clients send their username and password to server to verify, and server set the character ID to the client.
Is there any ways to do this?