Q:

Execute PHP script server side

Yesterday I created a script which is working fine, but only with an opened Web Browser which isn't that what I wanted. What I want is that the script runs all the time, even with closed Web Browser.
Could not upload a Picture, so its a short sketch:

(lookup.php) -> pass var data1 -> (run_code.php) -> pass var data1 ->
  (check.php) = {{refreshes every 5 seconds till var data2 exists in
  MySQl.}} -> goto -> lookup.php.....

The only problem is that I have no idea how to send a value from one .php file to another without GET,POST,COOKIE or SESSION. Session would be the best option but "lookup.php" is looking for a value, and if I start session I get the error "header is already set". 
So, how should I pass these value from "lookup.php" to "run_code.php"?
Second problem is, "check.php" is a code that checks if value exists in mysql. This code refreshed and executes itself after 5 seconds using META REFRESH. But also this is not working without a browser.
How should I write the script that the script executes itself after a time?

A:

If i understand you want to write a script (and choose php probably because your familiar with its syntax) and you need it to run every X minutes.
Problem is that when you write a web site with PHP you can pass information using HTTP methods (get/post) and using the session
when running a script on a machine you don't have the HTTP traffic and no session (this can be simulated but its a bit complicated)
my suggestion is : 
1) combine all the php files into 1 long php file that will be running (this way you can work with variables in the script with no problem) -  you can copy past your code into 1 php file and you can include the needed files in your script so you can stile keep the original files 
2) add a cron job (if its a Linux system) - http://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/  - this way your script with run every X time (your choice)

