php execution dilemma

cfleck

tired
i used php to create a site that keeps track of users hours at work. my current task it to automate the report generation at the end of each week.

in my "report generator" i used some functions that were written primarily for the web site. it all works fine so long as i execute the script via a browser. however, if i try to execute it via the command line it gives me an error that makes no sense to me. i've attached it at the bottom here. i need to set it up to automagically run every thursday at 4:00 for example.

i don't know if i'm running it correctly of it its even possible, but i just made the script executable and did a ./test.php

anyway, here is the error...

PHP:
./test.php: line 1: syntax error near unexpected token `dbConnectCEEO()'
?> 'st.psend_reports();k(date('d'));;
 
uh. dont you need to do something else to run php scripts at the CLI. normally they are parsed through Apache using the PHP module... have a look on the php.net site, or if you're using a *nix box for the system, you could write a small shell script and setup a cron task to run it each week..
 
that was the plan, to just use a cron task. but as you can see, the cli is causing me fits here. so basically, once i can get the cli going i should be fine.
 
My suggestion is to make an intermediate flash executable or an applescript that would navigate to the PHP script as a Web page through a browser.

PHP is not supposed to work when opened as a file into the broswer (double-clicked, or file-opened), it must be "browsed to" with "http://"
 
i'm not sure if i read you right, but i'm not trying to open it as a file in a browser. i want to execute it from the command line.
 
Well, from what I undersand, a php file cant be opened and run on its own. It must be accessed via "http://" for apache to activate php "service"

Have you tried using "http://127.0.0.1/yourscripthere.php" in your command line?
 
I think i understand what you wanna do:
You have a system set up to track something. It stores the data in either a dB, text files, XML files, whatever. Each week you want it to AUTOMATICALLY generate a report for you.

Does that sound about right??
 
thats right. and i just figured it out. i didn't know this but i had to install the php cli package first. its all fine now. the cron task is all that is left!
 
OH? What is the php cli package? does it allow standalone running of php scripts?
 
cool. if you aren't sure, there is probably a tool for GUI management of Cron tabs..
 
cool. If you want "bleeding edge" releases of apache/php/mysql, try Complete Apache 2.0, Complete MySQL and Complete PHP. They're installer packers (like the ones from entropy) that install almost up-to-the-minute versions of the three things. I cant fine the url right now, just search on google for "complete apache" or something.
 
Back
Top