[ticket/11660] Fix bugs from bugs in #11651 (missing vars, db->sql_connect)

http://tracker.phpbb.com/browse/PHPBB3-11660