mysql_connect() used twice
From: Alvaro G Vicario (alvaro_QUITAR_REMOVE_at_telecomputeronline.com)
Date: 08/31/04
- Next message: Alvaro G Vicario: "Re: mysql_connect() used twice"
- Previous message: Colin McKinnon: "Re: Urgent fopen question"
- Next in thread: Alvaro G Vicario: "Re: mysql_connect() used twice"
- Reply: Alvaro G Vicario: "Re: mysql_connect() used twice"
- Reply: Tony Marston: "Re: mysql_connect() used twice"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 31 Aug 2004 12:24:31 +0200
I need that my script retrieves data from two different databases so I use
mysql_connect() to open two connections. I have only one server, user and
password, just two different databases. Simplified, it'd be:
$con1=mysql_connect($server, $user, $pass);
mysql_select_db($database1, $con1);
$res1=mysql_query($sql1, $con1);
$con2=mysql_connect($server, $user, $pass);
mysql_select_db($database2, $con2);
$res2=mysql_query($sql2, $con2);
print_r($con1);
print_4($con2);
do_things_with_res1();
do_things_with_res2();
mysql_close($con2);
mysql_close($con1);
The problem is that, no matter what names I give to links and results, each
mysql_connect() overrides the previous ones. So when I call
do_things_with_res1() it actually uses $database2. The print_r() part shows
that $con1 has been unset!
I browsed php.ini and found this:
; Maximum number of links (persistent + non-persistent).
; -1 means no limit.
mysql.max_links = -1
I can't use only one connection because I have two different components
that are not necessarily called every time. I'm getting nuts so I'd really
appreciate any hint. Thank you in advance,
-- -- Álvaro G. Vicario - Burgos, Spain -- Questions sent to my mailbox will be billed ;-) --
- Next message: Alvaro G Vicario: "Re: mysql_connect() used twice"
- Previous message: Colin McKinnon: "Re: Urgent fopen question"
- Next in thread: Alvaro G Vicario: "Re: mysql_connect() used twice"
- Reply: Alvaro G Vicario: "Re: mysql_connect() used twice"
- Reply: Tony Marston: "Re: mysql_connect() used twice"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|