local var shadowing global var in function connect_db. fix.