PHP 4.3/MS-SQL7/IIS5.
At the start of every script, I include db.php which contains this:
<?
$db = mssql_connect('devbox','foo','bar');
mssql_select_db('[devsitedb]', $db) or die ("Couldn't open database
connection");
?>
And then I pass that connection into the various classes and functions
on the site. Fine and dandy.
However, in the course of one fo the scripts for this site, I need to
hook into a second database temporarily, so I do this at the
appropriate point:
<?
$second_db = mssql_connect('devbox','jim','bob');
mssql_select_db('[anothersitedb]', $second_db) or die ("Couldn't open
second database connection");
?>
Then do what I need to with that connection and close it with
<?
mssql_close($second_db);
?>
Here's the problem, though: despite the fact that the two connections
are clearly different, the second one is overwriting the first, so that
when I come back to doing things with the first connection, it now
can't find any of the stored procedures it needs. This is true at any
point after $second_db is opened, and it make no difference whether or
not I close $second_db. The connection is just being over-written.
At the point of opening, print_r($db) returns "Resource id #2". And
that holds true for the second connection as well - print_r($second_db)
also returns "Resource id #2".
mssql.max_links is set to -1, so there should be no problem with the
number of connections that I'm making...
Obviously, I would like it if this didn't happen, and $second_db become
"Resource id #3", thus allowing me to juggle the two connections as I
need to.
Anyone out there had similar problems, or able to spot what I'm missing? 2 3323 al*************@gmail.com wrote: PHP 4.3/MS-SQL7/IIS5.
At the start of every script, I include db.php which contains this: <? $db = mssql_connect('devbox','foo','bar'); mssql_select_db('[devsitedb]', $db) or die ("Couldn't open database connection"); ?>
And then I pass that connection into the various classes and functions on the site. Fine and dandy.
However, in the course of one fo the scripts for this site, I need to hook into a second database temporarily, so I do this at the appropriate point:
<? $second_db = mssql_connect('devbox','jim','bob'); mssql_select_db('[anothersitedb]', $second_db) or die ("Couldn't open second database connection"); ?>
Then do what I need to with that connection and close it with <? mssql_close($second_db); ?>
Here's the problem, though: despite the fact that the two connections are clearly different, the second one is overwriting the first, so that when I come back to doing things with the first connection, it now can't find any of the stored procedures it needs. This is true at any point after $second_db is opened, and it make no difference whether or not I close $second_db. The connection is just being over-written.
At the point of opening, print_r($db) returns "Resource id #2". And that holds true for the second connection as well - print_r($second_db) also returns "Resource id #2".
mssql.max_links is set to -1, so there should be no problem with the number of connections that I'm making...
Obviously, I would like it if this didn't happen, and $second_db become "Resource id #3", thus allowing me to juggle the two connections as I need to.
Anyone out there had similar problems, or able to spot what I'm missing?
Hi,
Just reconnect to the first DB after closing you second DB.
PHP will recycle the last used db, so you just have to point to the first
again, and can continue.
Regards,
Erwin Moller
With queries you can get around the problem with:
mssql_query ( $query1, $first_db);
mssql_query ( $query2, $second_db);
But for executes of stored procedures all you have is mixed
mssql_execute ( resource stmt [, bool skip_results] so it uses the
last connection resource opened.
A simple solution would then be to reformat the script so it works
like:
//Open db1
//Do all the db1 stuff
//close db 1
//Open db2
//Do all the db2 stuff
//close db 2 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Comcast Mail |
last post by:
|
by: Don Wash |
last post by:
Hi All!
I do not find any relevant newsgroups to post this question so I just posted
to this VB DotNet and General DotNet groups.
I'm trying to create a VB.NET application that will scan...
|
by: Christian McArdle |
last post by:
REQUEST FOR DISCUSSION (RFD)
unmoderated group comp.os.ms-windows.programmer.win64
This is a formal Request For Discussion (RFD) to create
comp.os.ms-windows.programmer.win64 as an unmoderated...
|
by: Christian McArdle |
last post by:
REQUEST FOR DISCUSSION (RFD)
unmoderated group comp.os.ms-windows.programmer.win64
This is a formal Request For Discussion (RFD) to create
comp.os.ms-windows.programmer.win64 as an unmoderated...
|
by: Christian McArdle |
last post by:
REQUEST FOR DISCUSSION (RFD)
unmoderated group comp.os.ms-windows.programmer.64bit
This is a formal Request For Discussion (RFD) to create
comp.os.ms-windows.programmer.64bit as an unmoderated...
|
by: mehrdad |
last post by:
Hi,
I have a fully functional MS-Access database.
May I build such an "exe" file from a MS-Access
"mdb" file which one who has not MS-Access
installed on his/her system can take advantage of the...
|
by: com |
last post by:
MS Access 2000 Password Recoverer 4.2 Screenshot - Soft30.com
MS Access 2000 Password Recoverer will display the password to a MS
Access
database (*.mdb). This program works for MS Access files...
|
by: Jordan S. |
last post by:
SQL Server will be used as the back-end database to a non trivial client
application.
In question is the choice of client application:
I need to be able to speak intelligently about when one...
|
by: Alex Martelli |
last post by:
So, I thought I'd tool up to let me build and test Python extensions on
Windows (as well as Mac and Linux) -- I'm trying out Parallels
Workstation beta on my new Macbook Pro (and so far it seems to...
|
by: PabsBath |
last post by:
Hello, help please.
I have been pulling my hair out for a few weeks now and been looking on the web for answers but not managed to find anything!!
I'm currently operating a small (2mb - approx...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |