Updating 2 Databases from a single form
Updating 2 Databases from a single form
am 27.09.2007 23:42:10 von Derek Moon
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
Re: Updating 2 Databases from a single form
am 28.09.2007 01:22:03 von Trevor Gryffyn
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"
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
>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Updating 2 Databases from a single form
am 28.09.2007 01:46:32 von Michael Preslar
On 9/27/07, Derek wrote:
> 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
>
>
mysql_connect($server, $user, $pass);
mysql_select_db($db1);
mysql_query($query1);
mysql_select_db($db2);
mysql_query($query2);
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: Updating 2 Databases from a single form
am 28.09.2007 03:15:20 von Bastien Koert
--_aa78e2b8-67d9-47b9-a056-56e8ce2a1196_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Realistically, there are three options:
=20
1. run the code twice to connect and pass the data to each server=20
2. set up a primary server and use a stored procedure to load the other ser=
ver (providing db supports it)
3. set up replication and make one a master and the other a slave and the t=
he replication do its work, the flip to this is to make each server a maste=
r and slave them off the other
=20
Bastien> To: php-db@lists.php.net> From: dmoon3@depaul.edu> Date: Thu, 27 S=
ep 2007 16:42:10 -0500> Subject: [PHP-DB] Updating 2 Databases from a singl=
e form> > Hello,> > I was wondering if there is anyway to first connect to =
two databases > simeltaneously. (both reside on the same server) . After co=
nnecting, I have > a single form that I want to use to update data to 2 dif=
ferent tables, both > tables are in different databases.> > So far I have r=
ecieved 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, v=
isit: http://www.php.net/unsub.php>=20
____________________________________________________________ _____
Invite your mail contacts to join your friends list with Windows Live Space=
s. It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=3Dcreate&wx_ url=3D/friends.=
aspx&mkt=3Den-us=
--_aa78e2b8-67d9-47b9-a056-56e8ce2a1196_--