jim white wrote:
I am running several web sites on one server, each of which connects to
a different Postgresql database. I use some include files to load
functions and classes. If I put pg_connect at the start of the include
file, then sometimes I do not connect to the correct database from
functions in a class. If I run echo pg_dbname(); in these functions I
see that I am connected to the wrong database. Here are some possible
The best solution is to work out why it's not connecting to the right db
in the first place, don't do any workarounds.
When it's wrong, what db is it connecting to? Can you work out a pattern?
You don't have a pg_connect() in one file and in another file is another
pg_connect() to a different database?
Do you have any pg_close() calls? When you call pg_query again it might
be after the db connection has been closed and so it creates a new
connection (to the wrong db).
Postgresql & php tutorials
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php