mysql_result needs 2 parameters. and it will only return 1 result, not all 3. fix this and I bet the rest go away.

mysql_result ( resource result, int row )

to get all the results you need mysql_fetch_array(), not mysql_result()

oh and

$LOGINQUERY

$loginquery

those are very different variables.