|
Posted by Gordon Burditt on 11/12/06 19:30
>> Don't use a database "as a default". Use it explicitly: pass the
>> appropriate connection handle to mysql_query().
>
>Unfortunately, this is not very convenient. The access to the 2nd database
>is a small addition to a large existing system that uses the 1st database. I
>don't really want to go through all the php code and change everything.
>Therefore, I really need a solution based on a default database that I can
>control. Why doesn't mysql_select_db() do this correctly?.
There is no default DATABASE; it's a default CONNECTION.
mysql_select_db() should have nothing whatever to do with which connection
is the default (unless it opens a new connection, which in your situation,
it doesn't).
I'd like to suggest that perhaps you don't need to open a second
connection. Use the first one and call mysql_select_db() to switch
back and forth. Now, this won't work if you need to call mysql_connect()
with different arguments, but I suspect you aren't doing that,
because you said the same resource id is being returned. Oh, yes,
because you only have one connection, closing the second one closes
the first one. Subsequent queries try to open a connection with
no username and no password, which should get permission errors.
You may find that inconvenient if you have to flip-flop between
databases with mysql_select_db() between queries.
Navigation:
[Reply to this message]
|