danianheron Posted March 18, 2011 Share Posted March 18, 2011 I downloaded this script of the net but I can't get it to work for me. the scrip is suppose to output a picture based on the time of day, but nothing happens. I need it to read the server's clock so that people all over the world will hear the DJ that the website indicates. the script (in a file called "picture.php" within the site's root directory) <?php $h = date('G'); //set variable $h to the hour of the day $d = date('w'); //set variable $d to the day of the week. $year = date('Y'); //set variable $year to the current year //G is the date key for hours in 24 format (not 12), with no leading 0s, like 02. // Adjust 2 hour offset for MST below. $h = $h-2; //G is the date key for hours in 24 format (not 12), with no leading 0s, like 02. // SUN SCHEDULE if ($d == 0 && $h >= 8 && $h < 10) { $img = 'images/talent_images/onairkeplersmooth.jpg'; else if ($d == 0 && $h >= 10 && $h < 12) { $img = 'images/talent_images/onairkepler20.jpg'; else if ($d == 0 && $h >= 12 && $h < 16) { $img = 'images/talent_images/onairkenny.jpg'; else if ($d == 0 && $h >= 16 && $h < 21) { $img = 'images/talent_images/onairnorman.jpg'; else if ($d == 0 && $h >= 21 && $h < 23) { $img = 'images/talent_images/onairpaul.jpg'; else if ($d == 0 && $h >= 23) { $img = 'images/talent_images/onairmaria.jpg'; else if ($d == 1 && $h < 0) { $img = 'images/talent_images/onairmaria.jpg'; // MON SCHEDULE if ($d == 1 && $h >= 0 && $h < { $img = 'images/talent_images/onairmaria.jpg'; else if ($d == 1 && $h >= 8 && $h < 12) { $img = 'images/talent_images/onairkennysandy.jpg'; else if ($d == 1 && $h >= 12 && $h < 14) { $img = 'images/talent_images/onairmiranda.jpg'; else if ($d == 1 && $h >= 14 && $h < 21) { $img = 'images/talent_images/onairdave.jpg'; else if ($d == 1 && $h >= 21 && $h < 23) { $img = 'images/talent_images/onairmaria.jpg'; else if ($d == 1 && $h >= 23) { $img = 'images/talent_images/onairmaria.jpg'; else if ($d == 2 && $h < 0) { $img = 'images/talent_images/onairmaria.jpg'; // TUES SCHEDULE if ($d == 2 && $h >= 0 && $h < { $img = 'images/talent_images/onairmaria.jpg'; else if ($d == 2 && $h >= 8 && $h < 12) { $img = 'images/talent_images/onairkennysandy.jpg'; else if ($d == 2 && $h >= 12 && $h < 14) { $img = 'images/talent_images/onairmiranda.jpg'; else if ($d == 2 && $h >= 14 && $h < 21) { $img = 'images/talent_images/onairdave.jpg'; else if ($d == 2 && $h >= 21 && $h < 23) { $img = 'images/talent_images/onairmaria.jpg'; else if ($d == 2 && $h >= 23) { $img = 'images/talent_images/onairmaria.jpg'; else if ($d == 3 && $h < 0) { $img = 'images/talent_images/onairmaria.jpg'; // WEDS SCHEDULE if ($d == 3 && $h >= 0 && $h < $img = 'images/talent_images/onairmaria.jpg'; else if ($d == 3 && $h >= 8 && $h < 12) $img = 'images/talent_images/onairkennysandy.jpg'; else if ($d == 3 && $h >= 12 && $h < 14) $img = 'images/talent_images/onairmiranda.jpg'; else if ($d == 3 && $h >= 14 && $h < 21) $img = 'images/talent_images/onairdave.jpg'; else if ($d == 3 && $h >= 21 && $h < 23) $img = 'images/talent_images/onairmaria.jpg'; else if ($d == 3 && $h >= 23) $img = 'images/talent_images/onairmaria.jpg'; else if ($d == 4 && $h < 0) $img = 'images/talent_images/onairmaria.jpg'; // THURS SCHEDULE if ($d == 4 && $h >= 0 && $h < { $img = 'images/talent_images/onairmaria.jpg'; else if ($d == 4 && $h >= 8 && $h < 12) { $img = 'images/talent_images/onairkennysandy.jpg'; else if ($d == 4 && $h >= 12 && $h < 14) { $img = $img = 'images/talent_images/onairmiranda.jpg'; else if ($d == 4 && $h >= 14 && $h < 21) { $img = 'images/talent_images/onairdave.jpg'; else if ($d == 4 && $h >= 21 && $h < 23) { $img = 'images/talent_images/onairmaria.jpg'; else if ($d == 4 && $h >= 23) { $img = 'images/talent_images/onairmaria.jpg'; else if ($d == 5 && $h < 0) { $img = 'images/talent_images/onairmaria.jpg'; // FRI SCHEDULE if ($d == 5 && $h >= 0 && $h < { $img = 'images/talent_images/onairmaria.jpg'; else if ($d == 5 && $h >= 8 && $h < 12) { $img = 'images/talent_images/onairkennysandy.jpg'; else if ($d == 5 && $h >= 12 && $h < 14) { $img = 'images/talent_images/onairmiranda.jpg'; else if ($d == 5 && $h >= 14 && $h < 21) { $img = 'images/talent_images/onairdave.jpg'; else if ($d == 5 && $h >= 21 && $h < 23) { $img = 'images/talent_images/onairmaria.jpg'; else if ($d == 5 && $h >= 23) { $img = 'images/talent_images/onairmaria.jpg'; else if ($d == 6 && $h < 0) { $img = 'images/talent_images/onairmaria.jpg'; // SAT SCHEDULE if ($d == 0 && $h >= 8 && $h < 10) { $img = 'images/talent_images/onairkeplersmooth.jpg'; else if ($d == 6 && $h >= 10 && $h < 12) { $img = 'images/talent_images/onairkepler20.jpg'; else if ($d == 6 && $h >= 12 && $h < 16) { $img = 'images/talent_images/onairkenny.jpg'; else if ($d == 6 && $h >= 16 && $h < 21) { $img = 'images/talent_images/onairnorman.jpg'; else if ($d == 6 && $h >= 21 && $h < 23) { $img = 'images/talent_images/onairpaul.jpg'; else if ($d == 6 && $h >= 23) { $img = 'images/talent_images/onairmaria.jpg'; else if ($d == 0 && $h < 0) { $img = 'images/talent_images/onairmaria.jpg'; echo '<a href="http://www.smoothjazznetwork.com"><img src="'.$img.'"></a>'; ?> then inside the html page where I want the pictures to show: <?php require ("picture.php"); ?> Please help, I'm at the end of my rope. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted March 18, 2011 Share Posted March 18, 2011 What shows up in the html markup when you do a View--->Source in your browser? Is the right value being added to the <img tag? Quote Link to comment Share on other sites More sharing options...
danianheron Posted March 18, 2011 Author Share Posted March 18, 2011 The browser indicates nothing - nothing to right click on. This is my test page: http://smoothjazznetwork.com/index-timetest.html By the way, thanks for replying and looking into this with me. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted March 18, 2011 Share Posted March 18, 2011 When posting code, please enclose it within the forum's . . . BBCode tags. That way it remains compact and gets highlighted like below. You've left every one of the curly braces unclosed in all of your if/elseif statements. That should clear up the parse errors, adn then you can see if it produces the result you want. <?php if ($d == 0 && $h >= 8 && $h < 10) { $img = 'images/talent_images/onairkeplersmooth.jpg'; } else if ($d == 0 && $h >= 10 && $h < 12) { $img = 'images/talent_images/onairkepler20.jpg'; } else if ($d == 0 && $h >= 12 && $h < 16) { $img = 'images/talent_images/onairkenny.jpg'; } else if ($d == 0 && $h >= 16 && $h < 21) { $img = 'images/talent_images/onairnorman.jpg'; } else if ($d == 0 && $h >= 21 && $h < 23) { $img = 'images/talent_images/onairpaul.jpg'; } else if ($d == 0 && $h >= 23) { $img = 'images/talent_images/onairmaria.jpg'; } else if ($d == 1 && $h < 0) { $img = 'images/talent_images/onairmaria.jpg'; } You should really be doing development with error_reporting = -1 and display_errors = On in your php.ini file. It would save you a lot of time to have errors like this reported. Quote Link to comment Share on other sites More sharing options...
danianheron Posted March 18, 2011 Author Share Posted March 18, 2011 I actually took those brackets off thinking they were the problem. The script didn't work with them in the file, but I will try again. Furthermore, I am not aware of a php.ini file. where would I find that? Forgive my ignorance. Your point about the enclosing my codes is well taken. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted March 18, 2011 Share Posted March 18, 2011 If you create a new script and in it place the following code, it will list the location of the php.ini file that is being used by php. Keep in mind that display_errors should be used when developing, but on a live, production server, you'd want to log them instead. <?php phpinfo(); ?> Quote Link to comment Share on other sites More sharing options...
danianheron Posted March 19, 2011 Author Share Posted March 19, 2011 Still no output... my php file as it stands now <?php $h = date('G'); //set variable $h to the hour of the day $d = date('w'); //set variable $d to the day of the week. $year = date('Y'); //set variable $year to the current year //G is the date key for hours in 24 format (not 12), with no leading 0s, like 02. // Adjust 2 hour offset for MST below. $h = $h-2; //G is the date key for hours in 24 format (not 12), with no leading 0s, like 02. // SUN SCHEDULE if ($d == 0 && $h >= 8 && $h < 10) { $img = 'images/talent_images/onairkeplersmooth.jpg'; } else if ($d == 0 && $h >= 10 && $h < 12) { $img = 'images/talent_images/onairkepler20.jpg'; } else if ($d == 0 && $h >= 12 && $h < 16) { $img = 'images/talent_images/onairkenny.jpg'; } else if ($d == 0 && $h >= 16 && $h < 21) { $img = 'images/talent_images/onairnorman.jpg'; } else if ($d == 0 && $h >= 21 && $h < 23) { $img = 'images/talent_images/onairpaul.jpg'; } else if ($d == 0 && $h >= 23) { $img = 'images/talent_images/onairmaria.jpg'; } else if ($d == 1 && $h < 0) { $img = 'images/talent_images/onairmaria.jpg'; } // MON SCHEDULE if ($d == 1 && $h >= 0 && $h < { $img = 'images/talent_images/onairmaria.jpg'; } else if ($d == 1 && $h >= 8 && $h < 12) { $img = 'images/talent_images/onairkennysandy.jpg'; } else if ($d == 1 && $h >= 12 && $h < 14) { $img = 'images/talent_images/onairmiranda.jpg'; } else if ($d == 1 && $h >= 14 && $h < 21) { $img = 'images/talent_images/onairdave.jpg'; } else if ($d == 1 && $h >= 21 && $h < 23) { $img = 'images/talent_images/onairmaria.jpg'; } else if ($d == 1 && $h >= 23) { $img = 'images/talent_images/onairmaria.jpg'; } else if ($d == 2 && $h < 0) { $img = 'images/talent_images/onairmaria.jpg'; } // TUES SCHEDULE if ($d == 2 && $h >= 0 && $h < { $img = 'images/talent_images/onairmaria.jpg'; } else if ($d == 2 && $h >= 8 && $h < 12) { $img = 'images/talent_images/onairkennysandy.jpg'; } else if ($d == 2 && $h >= 12 && $h < 14) { $img = 'images/talent_images/onairmiranda.jpg'; } else if ($d == 2 && $h >= 14 && $h < 21) { $img = 'images/talent_images/onairdave.jpg'; } else if ($d == 2 && $h >= 21 && $h < 23) { $img = 'images/talent_images/onairmaria.jpg'; } else if ($d == 2 && $h >= 23) { $img = 'images/talent_images/onairmaria.jpg'; } else if ($d == 3 && $h < 0) { $img = 'images/talent_images/onairmaria.jpg'; } // WEDS SCHEDULE if ($d == 3 && $h >= 0 && $h < { $img = 'images/talent_images/onairmaria.jpg'; } else if ($d == 3 && $h >= 8 && $h < 12) { $img = 'images/talent_images/onairkennysandy.jpg'; } else if ($d == 3 && $h >= 12 && $h < 14) { $img = 'images/talent_images/onairmiranda.jpg'; } else if ($d == 3 && $h >= 14 && $h < 21) { $img = 'images/talent_images/onairdave.jpg'; } else if ($d == 3 && $h >= 21 && $h < 23) { $img = 'images/talent_images/onairmaria.jpg'; } else if ($d == 3 && $h >= 23) { $img = 'images/talent_images/onairmaria.jpg'; } else if ($d == 4 && $h < 0) { $img = 'images/talent_images/onairmaria.jpg'; } // THURS SCHEDULE if ($d == 4 && $h >= 0 && $h < { $img = 'images/talent_images/onairmaria.jpg'; } else if ($d == 4 && $h >= 8 && $h < 12) { $img = 'images/talent_images/onairkennysandy.jpg'; } else if ($d == 4 && $h >= 12 && $h < 14) { $img = $img = 'images/talent_images/onairmiranda.jpg'; } else if ($d == 4 && $h >= 14 && $h < 21) { $img = 'images/talent_images/onairdave.jpg'; } else if ($d == 4 && $h >= 21 && $h < 23) { $img = 'images/talent_images/onairmaria.jpg'; } else if ($d == 4 && $h >= 23) { $img = 'images/talent_images/onairmaria.jpg'; } else if ($d == 5 && $h < 0) { $img = 'images/talent_images/onairmaria.jpg'; } // FRI SCHEDULE if ($d == 5 && $h >= 0 && $h < { $img = 'images/talent_images/onairmaria.jpg'; } else if ($d == 5 && $h >= 8 && $h < 12) { $img = 'images/talent_images/onairkennysandy.jpg'; } else if ($d == 5 && $h >= 12 && $h < 14) { $img = 'images/talent_images/onairmiranda.jpg'; } else if ($d == 5 && $h >= 14 && $h < 21) { $img = 'images/talent_images/onairdave.jpg'; } else if ($d == 5 && $h >= 21 && $h < 23) { $img = 'images/talent_images/onairmaria.jpg'; } else if ($d == 5 && $h >= 23) { $img = 'images/talent_images/onairmaria.jpg'; } else if ($d == 6 && $h < 0) { $img = 'images/talent_images/onairmaria.jpg'; } // SAT SCHEDULE if ($d == 0 && $h >= 8 && $h < 10) { $img = 'images/talent_images/onairkeplersmooth.jpg'; } else if ($d == 6 && $h >= 10 && $h < 12) { $img = 'images/talent_images/onairkepler20.jpg'; } else if ($d == 6 && $h >= 12 && $h < 16) { $img = 'images/talent_images/onairkenny.jpg'; } else if ($d == 6 && $h >= 16 && $h < 21) { $img = 'images/talent_images/onairnorman.jpg'; } else if ($d == 6 && $h >= 21 && $h < 23) { $img = 'images/talent_images/onairpaul.jpg'; } else if ($d == 6 && $h >= 23) { $img = 'images/talent_images/onairmaria.jpg'; } else if ($d == 0 && $h < 0) { $img = 'images/talent_images/onairmaria.jpg'; } echo '<a href="http://www.smoothjazznetwork.com"><img src="'.$img.' width="200" height="76" "></a>'; ?> Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted March 19, 2011 Share Posted March 19, 2011 It seems to work fine when I paste it in and run it locally. Have you checked the raw markup with View--->Source to see if it appears there? Quote Link to comment Share on other sites More sharing options...
danianheron Posted March 19, 2011 Author Share Posted March 19, 2011 I'm using dreamweaver to edit. Do you mean that I should do a "live view" within dreamweaver (DW)? When I do that DW tells me that I'm trying to use a serverside script and that I need to set it up. It never works for me them DW just ends up displaying the text of the scrip in the viewing area. That's amazing - it works for you. What in the world am I missing here? Am I calling it correctly from my main page? <?php require ("picture.php"); ?> does there needs to some statement in the <head> of my page? how is the identical file working for you and not for me? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted March 19, 2011 Share Posted March 19, 2011 Php is a server-side scripting language. It gets added to a web server so that .php code will be parsed and interpreted on the server when .php pages are requested by the browser. DW has never been very server-side friendly. You either need to install a web server with php on your local development computer (there are all-in-one packages, such as http://www.apachefriends.org/en/xampp.html ) or test your code on your 'live' web server. Quote Link to comment Share on other sites More sharing options...
danianheron Posted March 19, 2011 Author Share Posted March 19, 2011 I understand. I uploaded my files and it still wont work for me. Did you note my other questions in my last reply? Am I calling the php file correctly? Is some type of statement needed in the <head> of my main file. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted March 19, 2011 Share Posted March 19, 2011 When you call the page on the live server into your web browser, do a View--->Source and see if the html markup for the image: <a href="http://www.smoothjazznetwork.com"><img src="'.$img.' width="200" height="76" "></a> is anywhere to be found, and if it has one of the image filenames for the src= attribute. Quote Link to comment Share on other sites More sharing options...
danianheron Posted March 19, 2011 Author Share Posted March 19, 2011 It is nowhere to be found. This is what shows <td width="213" height="80" align="center" valign="middle"><?php require ("picture.php"); ?></td> <td width="385"><img src="images/listenlive.png" width="385" height="78" border="0" usemap="#Map3"> <map name="Map3"> it does not seem to be running picture.php Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted March 19, 2011 Share Posted March 19, 2011 If that's the html output, then the php interpreter isn't parsing the file. Does it have a .php file extension, and are you sure the server supports php? Quote Link to comment Share on other sites More sharing options...
danianheron Posted March 19, 2011 Author Share Posted March 19, 2011 this is the status of my server: php.ini http://www.smoothjazznetwork.com/phpinfo.php and yes the file does have a php extension Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted March 19, 2011 Share Posted March 19, 2011 Where is it supposed to be, because I can't find any of the markup you posted above anywhere on the main page of the site? Quote Link to comment Share on other sites More sharing options...
danianheron Posted March 19, 2011 Author Share Posted March 19, 2011 figured it out. the code was ok. Dreamweaver has a function to include a serverside script - I did that and it worked. I can't tell you how much I appreciate your help and patience. inside my webpage: <!--#include file="picture.php" --> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.