Undefined variable?

my bad, i had the connection string outside the function