|
Posted by Jerry Stuckle on 11/24/06 21:19
Joachim Smit wrote:
>
> I want store data in 2 different database, just for backup. One database
> is located at the webserver, the 2nd one on another server.
>
> I've writte this little script to test it.
>
> <?php
> $db1 = pg_connect("host=123.123.123.123 dbname=test user=usrphp");
> $cmd = "insert into website (ipnr, page) values ('777', 'main')";
> $result = pg_query($db1, $cmd);
>
> $db2 = pg_connect("dbname=test user=usrphp");
> $cmd = "insert into website (ipnr, page) values ('777', 'main')";
> $result = pg_query($db2, $cmd);
>
> echo ($db1);
> echo ("\n");
>
> echo ($db2);
> echo ("\n");
>
> pg_close($db1);
> pg_close($db2);
>
> ?>
>
> When I call this script from the command prompt, I get the result:
>
> Resource id #1
> Resource id #3
>
> and the data is written to both databases.
>
> When I call the script with a browser from outside, I get the result:
>
> Resource id #2
>
> Data is written only to the local database.
>
> Why ?
>
>
> Many thanks in advance.
>
> Joachim
Which is just what should happen.
When you run it from the command line on your machine, $db2 will be a
connection to your machine, because that's where the PHP is running.
When you execute it from a browser, the script is being executed by the
server, and $db2 would point to a database one the server - which would
be something entirely different.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|