For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > September 2007 > Re: [PHP-DB] Updating 2 Databases from a single form









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] Updating 2 Databases from a single form
TG

2007-09-27, 10:00 pm


If both the databases are on the same database server, you can use the SQL
command "USE dbname" to switch databases or use the full "path" like
"dbone.tablename.columnname" and "dbtwo.tablename.columnname".

Or you can use mysql_select_db() PHP function to switch databases on the same
server.

Assuming that you're talking about two different database servers, then you
can just do two separate connections:

$conn1 = mysql_connect($server1, $user, $pass);
$conn2 = mysql_connect($server2, $user, $pass);

$result1 = mysql_query($somequery, $conn1);
$result2 = mysql_query($somequery, $conn2);

Something like that.

-TG

----- Original Message -----
From: "Derek" <dmoon3@depaul.edu>
To: php-db@lists.php.net
Date: Thu, 27 Sep 2007 16:42:10 -0500
Subject: [PHP-DB] Updating 2 Databases from a single form

> Hello,
>
> I was wondering if there is anyway to first connect to two databases
> simeltaneously. (both reside on the same server) . After connecting, I have
> a single form that I want to use to update data to 2 different tables, both
> tables are in different databases.
>
> So far I have recieved at least 10 ways of doing this and none of them seem
> to work.
> I know there is a way, but I cant seem to grasp it from the information
> that
> I have acquired so far.
>
> Important Facts
> Both databases have the same login credentials,
> Both databases are on the same server,
>
>
> Any ideas?
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com