PDA

View Full Version : Quote of the day cron job help needed



coinmagnate
05-12-2008, 09:29 AM
I'm trying to set up what sounds like it should be a simple quote of the day script on my page at: http://thewebworks.us/policies.htm.
I don't know much about scripting and I don't know anything about cron jobs but I know I need to configure one for this script but I can't find it on Bluehost.
Here are my files I'm trying to use: http://thewebworks.us/qotd/
Can someone please help me configure the cron job to make this script work?

Thank you so much,
Janet

djmatt
05-26-2008, 06:42 PM
First, your php code is showing up in the html code, so it is not being processed correctly. I don't know how to do cron jobs, but I do know how to work around my limitations. What I would do is use php to find out the date and select the date number (1-31)

Then use the php date to decide what quote to print.
if (date("j") == 1) { echo "penny saved";}
if (date("j") == 2) { echo "silence golden";}

you could even repeat if needed...
if (date("j") == 21) { echo "penny saved";}
if (date("j") == 22) { echo "silence golden";}

Eriksrocks
05-27-2008, 03:17 PM
You could just use a PHP script for this that runs every time the user visits the page and delivers the appropriate quote based on what date it is, similar to djmatt's example. :)

You don't need a cron job for this. :rolleyes:

Eriksrocks
05-27-2008, 03:29 PM
If I were you I would use a switch statement rather than multiple ifs to streamline the code. Here is an example of what I would use:


<?php

switch(date("j"))
{
case 1 : echo("To be or not to be, that is the question."); break;
case 2 : echo("One small step for man, one giant leap for mankind."); break;
case 3 : echo("I came, I saw, I conquered."); break;\
// etc. add 31 cases in the same format for 31 different quotes
default : echo("Sorry, no quote today!");
}

?>

Hope that works for you. :)