Fixes #770 'lastip' SQL error when no IP is present

#770