Reply to opening a page with the sole purpose of running an sql statement

Your name:

Reply:


Posted by windandwaves on 10/09/06 00:39

Hi Folk

I am running a site (A) that has a US mirror (B). This means that all
the data from A is copied daily to B.

On the site, I keep some statistics of the pages people visit, tracking
them with a session and noting their searches, etc... for statistical
purposes.

The problem I have is that if someone visits site B then at the end of
the day, their statistical data is going to be overriden by the update
from A.

To counter this, I envisaged a system where the stats dont just run an
sql statement to update my MySql database, but instead, the statements
"include" a URL on A that runs the statement.

For example:

---
Old procedure:
function add_user_page() {
mysql_query("INSERT INTO USER (PAGEID, USERID) VALUES (1,2);");
}

---
New procedure:
function add_user_page() {
if(site B) {

include_once("http://A.com/runstats.php?function=add_user_pageB&table=USER&V1=8&V2=9");
}
mysql_query("INSERT INTO USER (PAGEID, USERID) VALUES (8,9);");
}

---
I would then create a file runstats.php with the following code:

<?php
call_user_function($_GET["function"], $_GET);
function add_user_pageB ($name, $v1, $v2) {
mysql_query("INSERT INTO USER (PAGEID, USERID) VALUES
('.$v1.','.$v2.');");
}
?>

This is obviously super simplified and not tested.

The questions I have are

1. is this a good method?
2. can I / should I use "include_once" or is there a better way to run
(call) the runstats.php page?

NOTE: my ISP does not allow me to connect directly from B to the
database on A.

Thanks in advance for any comments

Nicolaas

[Back to original 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

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