Fix error when no connection opened

"pg_last_error(): No PostgreSQL link opened yet"