Re: Connecting to MySQL database
| From: | David Otton | Date: | Mon, 08 Oct 2001 13:25:00 +0000 |
| Subject: | Re: Connecting to MySQL database | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-70353@lists.php.net to get a copy of this message | ||
On Fri, 8 Jun 2001 16:09:35 +0300, you wrote:
>Try do not close connection within function B():
What happens if I reuse func_b() in a position where it isn't called
by func_a()?
>function a() {
> connect_to_database_A;
> connect_to_database_B; // only if you A and B are different
> // database type or hosts (!)
>
> run_query;
> for(...) {
> echo(b(some_data));
> }
> close_connection_A;
> close_connection_B; // see note above
>}
>
>function b(data) {
> run_query(data);
> return (condition ? "good" : "bad");
>}
Ok, I've tried it, by passing the resource into func_b(), but it fails
with the same error.
>DO> Warning: 3 is not a valid MySQL-Link resource in C:\Program
>DO> Files\Internet\Apache\Apache\htdocs/show_board.php on line 78
I assume that func_b()'s call to mysql_query() is in some sense
"overwriting" func_a()'s... or maybe that the passed-in resource is
closed implicitly when the function ends (unlikely).
I /really/ don't want to make the database connector global here,
that's a nasty solution. MySQL can certainly handle multiple open
connections... how do I create them at the PHP end?
djo