Hi all I am doing a module where I need to use 2 database . I start First database and select some data by using while loop. Inside While Lopp I need to open other Second database to insert some data from first BD, If any idea pls provide , I am using Php and SQL server. Many thx.
How to use 2 database in Php?
Collapse
X
-
I connect with first database & after that I run a query which is getting data by while loop . and inside while loop i need to connect with other database to insert data into second DB. I tried normal connection such asOriginally posted by r035198xWhat have you tried so far?
[code=php]
$con = mssql_connect(' localhost','php web','phpweb', 'TG') or die("Error: Could not connect to DB Server"); [/code]
Is there any way to possibly solusion?Comment
-
Heya, Shaif.
You should consider connecting to the second database *outside* the loop and using that connection resource where you need it.
Note that mssql_query() takes a second parameter - the database connection resource (e.g., $con). Use this to direct which connection will receive the query (http://php.net/mssql_query).Comment
Comment