Looking for volunteers to join your project? Need help with a script but can't afford to pay? Want to offer your services as a volunteer to build up your portfolio? This is the place for you...
Moderator: General Moderators
Neostars
Forum Newbie
Posts: 6 Joined: Mon Jul 31, 2006 5:37 pm
Post
by Neostars » Mon Jul 31, 2006 5:54 pm
I need help with a script.
It needs to change at 12 o'clock every, and change back at 1 o'clock.
Example-
(Before 12):
Hello How Are You
(After 12):
I'm Fine.
Here's a example in use:
http://www.nhfa.net/
On the right hand panel it says Alerts. Every day at 10, and 4 it changed saying the 'Snowager' is asleep.
I need that exact code they use for my site.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Jul 31, 2006 8:04 pm
here's the places to start:
time() and
date() , mix a few if's in for flavor and presto, you can do it too.
Neostars
Forum Newbie
Posts: 6 Joined: Mon Jul 31, 2006 5:37 pm
Post
by Neostars » Tue Aug 01, 2006 8:24 am
Yes, But I don't even have the basic Knowledge of PHP.
This is what I have so far, and it keeps messing up the page saying:
Parse Error
Or
Unexpected '}' on line 99
Or
Parse Error...Blah...T_ELSE on Line 99.
Here's my script:
Code: Select all
<?PHP
$weekDay = date('D'); // Mon - Sun
$hour = date('G'); // 0 - 23
$displayDates = array("Mon", "Tue", "Wed", "Thu", "Fri");
$displayHours = array(6, 14, 22);
if(in_array($weekDay, $displayDates) and in_array($hour, $displayHours))
{"$image = "snowasleep.jpg"}
else{"$image = "snowawake.jpg"}
echo{
"<a href="http://www.neopets.com/winter/snowager.phtml"><img src="http://www.neostars.co.uk/images/layout/new/snowawake.jpg">
Can somebody fix it for me?
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Tue Aug 01, 2006 8:34 am
Code: Select all
<?PHP
$weekDay = date('D'); // Mon - Sun
$hour = date('G'); // 0 - 23
$displayDates = array("Mon", "Tue", "Wed", "Thu", "Fri");
$displayHours = array(6, 14, 22);
if(in_array($weekDay, $displayDates) && in_array($hour, $displayHours))
{
$image = "snowasleep.jpg";
}
else
{
$image = "snowawake.jpg";
}
echo '<a href="http://www.neopets.com/winter/snowager.phtml"><img src="http://www.neostars.co.uk/images/layout/new/'.$image.'">';
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Tue Aug 01, 2006 8:46 am
Post all your code, using the correct tags
Neostars
Forum Newbie
Posts: 6 Joined: Mon Jul 31, 2006 5:37 pm
Post
by Neostars » Tue Aug 01, 2006 8:51 am
This is what I have so far. Sorry if I messed up.
Code: Select all
<?PHP
$weekDay = date('D'); // Mon - Sun
$hour = date('G'); // 0 - 23
$displayDates = array("Mon", "Tue", "Wed", "Thu", "Fri");
$displayHours = array(6, 14, 22);
if(in_array($weekDay, $displayDates) && in_array($hour, $displayHours))
{$image="snowasleep.jpg"
else{$image="snowawake.jpg"
echo"<a href="http://www.neopets.com/winter/snowager.phtml"><img src="http://www.neostars.co.uk/images/layout/new/"$image">
But look what it does to the page:
http://neostars.co.uk/portal2.php
nickvd
DevNet Resident
Posts: 1027 Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:
Post
by nickvd » Tue Aug 01, 2006 3:53 pm
Give This a try... please note: you need to end your lines with a semi colon (;) and your logic structures need closing curly braces ala:
Code: Select all
if (something) {
//do this
} else {
/do this
}
This code seems to work (all i did was fix the errors you had in yours)
Code: Select all
$weekDay = date('D'); // Mon - Sun
$hour = date('G'); // 0 - 23
$displayDates = array("Mon", "Tue", "Wed", "Thu", "Fri");
$displayHours = array(6, 14, 22);
if(in_array($weekDay, $displayDates) && in_array($hour, $displayHours)) {
$image="snowasleep.jpg";
} else {
$image="snowawake.jpg";
}
echo '<a href="http://www.neopets.com/winter/snowager.phtml"><img src="http://www.neostars.co.uk/images/layout/new/'.$image.'">';
Neostars
Forum Newbie
Posts: 6 Joined: Mon Jul 31, 2006 5:37 pm
Post
by Neostars » Tue Aug 01, 2006 4:30 pm
Code: Select all
<?PHP
$weekDay = date('D'); // Mon - Sun
$hour = date('G'); // 0 - 23
$displayDates = array("Mon", "Tue", "Wed", "Thu", "Fri");
$displayHours = array(5, 14, 22);
if(in_array($weekDay, $displayDates) && in_array($hour, $displayHours))
{
$image = "snowasleep.jpg";
}
else
{
$image = "snowawake.jpg";
}
echo '<a href="http://www.neopets.com/winter/snowager.phtml"><img src="http://www.neostars.co.uk/images/layout/new/'.$image.'"></a>';
?>
Everything works EXCEPT the timing. Does it sync with my computer?
Which part effects time? For me I need it to change to the 'snowasleep' at 5 o'clock.
How?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Aug 01, 2006 4:38 pm
date() uses the server's internal time. If you want to adjust the time it references, read up on unix timestamps and the date function at the documentation link provided.
Neostars
Forum Newbie
Posts: 6 Joined: Mon Jul 31, 2006 5:37 pm
Post
by Neostars » Wed Aug 02, 2006 9:50 am
This topic can be closed. The code works and I don't need help anymore. Thanks