Good day!
I am trying to create a script that checks what the current conditions are (DONE now via php call using API to wunderground) and then a second variable getting if it is night or day.
I am a bit shaky on this. I installed the sunrise-sunset.php file from Mike Challis, and then in my page I added
include 'sunrise-sunset.php';
which I hope would pull in the variable, one of which is $dayornight. So, I am hoping my code would do an if variable1 = true && variable2 = true do this, elseif do something else.
But, I am getting an error on this:
Parse error: syntax error, unexpected 'and' (T_LOGICAL_AND) in /homepages/17/d554858752/htdocs/DEADCOWZdomainroot/wuapicall2.php on line 8
Here is some of the code on my page.
The top section is the API call (API changed for the forum), the second part is the include, then the logic part where it determines which image to copy and name as current.jpg. This DOES work without the && part, but not with it. Adding the AND breaks it.
<?php $json_string = file_get_contents("http://api.wunderground.com/api/3aa3d2f44c50a999/geolookup/conditions/q/VT/Jericho.json");
$parsed_json = json_decode($json_string);
$weather = $parsed_json->{'current_observation'}->{'weather'};
include 'sunrise-sunset.php';
if (in_array($weather, array('Mostly Cloudy', 'Cloudy', 'Partly Cloudy', 'Overcast'))) and ($dayornight =='night')
{
copy("/kunden/homepages/17/d554858752/htdocs/DEADCOWZdomainroot/images/current/nightcloudy.jpg", "/kunden/homepages/17/d554858752/htdocs/DEADCOWZdomainroot/images/current/current.jpg");
}
elseif (in_array($weather, array('Mostly Cloudy', 'Cloudy', 'Partly Cloudy', 'Overcast'))) and ($dayornight =='day')
{
copy("/kunden/homepages/17/d554858752/htdocs/DEADCOWZdomainroot/images/current/daycloudy.jpg", "/kunden/homepages/17/d554858752/htdocs/DEADCOWZdomainroot/images/current/current.jpg");
}
I have searched google for this error and tried both && and 'and', removed the parentheses around the $dayornight =='night' but it always throws this error.
I set up a CRON job to run this page every 15 minutes to update the current.jpg
Any assistance would be appreciated!
Thank you!
Phil