You are here: No connection with database « PHP Programming Language « IT news, forums, messages
No connection with database

Posted by Joachim Smit on 11/24/06 20:26

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация