Parse error: syntax error, unexpected $end on line 28
Here is the PHP Code:
As you can see, it is suppose to show an image that will allow people to popup a chat to listen to a live podcast/show, at given times of given days.
PHP Code:
<?php //Get the current hour (1-24) / Date $time = date('H'); $day = date('D');
//Show Name is Live (16-18 on Mons-Weds & Fridays) if($time = 16 and $time < 18 && $day = Monday and $day < Wednesday and $day = Friday ) { //Live Code echo 'Live Now - Image/Popup Link goes here for Chat'; } //Show Name is Live (19-20 on Wednesdays) if($time = 19 and $time < 20 && $day = Wednesday){ //Live Code echo 'Live Now - Image/Popup Link goes here for Chat'; //Show Name is Live (16 - 18 on Thursdays) if($time = 16 and $time < 18 && $day = Thursday){ //Live Code echo 'Live Now - Image/Popup Link goes here for Chat'; //Show Name is Live (20-22 on Fridays) if($time = 20 and $time < 22 && $day = Friday){ //Live Code echo 'Live Now - Image/Popup Link goes here for Chat'; //Otherwise, We're Offair }else{ //Offair Code echo 'We are Currently offair. PopUp Link is here - Offair Chat... '; } ?>
<?php //Get the current hour (1-24) / Date $time = date('H'); $day = date('D'); $daynum = intval(date('N')); // need this to return an int
//Show Name is Live (16-18 on Mons-Weds & Fridays) if($time == 16 && $time < 18 && (($day == 'Mon' and $daynum < 3) || $day == 'Fri') ) { //Live Code echo 'Live Now - Image/Popup Link goes here for Chat'; } //Show Name is Live (19-20 on Wednesdays) if($time == 19 && $time < 20 && $day == 'Wed'){ //Live Code echo 'Live Now - Image/Popup Link goes here for Chat'; } //Show Name is Live (16 - 18 on Thursdays) if($time == 16 && $time < 18 && $day == 'Thu'){ //Live Code echo 'Live Now - Image/Popup Link goes here for Chat'; } //Show Name is Live (20-22 on Fridays) if($time == 20 && $time < 22 && $day == 'Fri'){ //Live Code echo 'Live Now - Image/Popup Link goes here for Chat'; //Otherwise, We're Offair }else{ //Offair Code echo 'We are Currently offair. PopUp Link is here - Offair Chat... '; } ?>
Your first if statement is lacking some logic. $day returns a string and you are trying use a < operator but because they aren't numbers it will fail. You also need to be using == to compare numbers and string. I think you need to use && as well. You may be able to use AND not sure.
$day will also never return any of the days you are comparing so it will always be offline. You need to compare to the first 3 letters. Your first if statement will never be true as it can't be Monday AND Friday at the same time.
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
<a href="#webClient" onclick="window.open('link to chat', 'Web Client','width=800,height=600,menubar=0,toolbar=0,status=0,scrollbars=0,resizable=1')"><img src="link to image"></a>
it errors out?
Error:
Quote:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' on line 9
PHP Code:
PHP Code:
<?php //Get the current hour (1-24) / Date $time = date('H'); $day = date('D'); $daynum = intval(date('N')); // need this to return an int
//Show Name is Live (16-18 on Mons-Weds & Fridays) if($time == 16 && $time < 18 && (($day == 'Mon' and $daynum < 3) || $day == 'Fri') ) { //Live Code echo '<a href="#webClient" onclick="window.open('link to chat', 'Web Client','width=800,height=600,menubar=0,toolbar=0,status=0,scrollbars=0,resizable=1')"><img src="link to image"></a>'; } //Show Name is Live (19-20 on Wednesdays) if($time == 19 && $time < 20 && $day == 'Wed'){ //Live Code echo 'Live Now - Image/Popup Link goes here for Chat'; } //Show Name is Live (16 - 18 on Thursdays) if($time == 16 && $time < 18 && $day == 'Thu'){ //Live Code echo 'Live Now - Image/Popup Link goes here for Chat'; } //Show Name is Live (20-22 on Fridays) if($time == 20 && $time < 22 && $day == 'Fri'){ //Live Code echo 'Live Now - Image/Popup Link goes here for Chat'; //Otherwise, We're Offair }else{ //Offair Code echo 'We are Currently offair. PopUp Link is here - Offair Chat... '; } ?>
Thanks. It worked.. btw, my first written full PHP script.
You don't need to use intval. If you compare a numeric string, it'll be handled fine.
Your problem appears to be extensive logic errors. For instance, why are you doing this?
PHP Code:
if($time == 20 && $time < 22 && $day == 'Fri'){
If $time is 20 then you already know that it's less than 22. Do you possibly mean this?
PHP Code:
if($time >= 20 && $time < 22 && $day == 'Fri'){
Yes, That possibly is the code I should be using - Tested.. And results below.
Here is the Code I am using now:
PHP Code:
<?php //Get the current hour (1-24) / Date $time = date('H'); $day = date('D'); $daynum = intval(date('N')); // need this to return an int
//Show Name is Live (16-18 on Mons-Weds & Fridays) if($time >= 16 && $time < 18 && (($day == 'Mon' and $daynum < 3) || $day == 'Fri') ) { //Live Code echo '<br/><h2>Live</h2><br/><a href="#webClient" onclick="window.open(\'/path/to/webchat\', \'Web Client\',\'width=800,height=600,menubar=0,toolbar=0,status=0,scrollbars=0,resizable=1\')"><img src="/path/to/image"></a></br>... You can also use our Community Chat (Coming Soon!).'; } //Show Name is Live (19-20 on Wednesdays) if($time >= 19 && $time < 20 && $day == 'Wed'){ //Live Code echo '<br/><h2>Live</h2><br/><a href="#webClient" onclick="window.open(\'/path/to/webchat\', \'Web Client\',\'width=800,height=600,menubar=0,toolbar=0,status=0,scrollbars=0,resizable=1\')"><img src="/path/to/image"></a></br>... You can also use our Community Chat (Coming Soon!).'; } //Show Name is Live (16 - 18 on Thursdays) if($time >= 16 && $time < 18 && $day == 'Thu'){ //Live Code echo '<br/><h2>Live</h2><br/><a href="#webClient" onclick="window.open(\'/path/to/webchat\', \'Web Client\',\'width=800,height=600,menubar=0,toolbar=0,status=0,scrollbars=0,resizable=1\')"><img src="/path/to/image"></a></br>... You can also use our Community Chat (Coming Soon!).'; } //Show Name is Live (20-22 on Fridays) if($time >= 20 && $time < 22 && $day == 'Fri'){ //Live Code echo '<br/><h2>Live</h2><br/><a href="#webClient" onclick="window.open(\'/path/to/webchat\', \'Web Client\',\'width=800,height=600,menubar=0,toolbar=0,status=0,scrollbars=0,resizable=1\')"><img src="/path/to/image"></a></br>... You can also use our Community Chat (Coming Soon!).'; //Otherwise, We're Offair }else{ //Offair Code echo 'We are Currently offair. Chat with the Community using the Community Chat. <center><strong>(Coming Soon!)</strong></center> '; } ?>
Still getting:
Quote:
We are Currently offair. Chat with the Community using the Community Chat. (Coming Soon!)