dreamwest Posted January 22, 2009 Share Posted January 22, 2009 I can tget this if else to work....and its driving me insane! if (isset($_COOKIE['autoplay'])){ echo ""; }else{ echo "<a href=\"javascript: set_cookie('autoplay', 'on');\">Turn Autoplay ON</a><br>Plays Videos Automatically<br><hr>"; } if ($_COOKIE['autoplay'] === 'on'){ echo "<a href=\"javascript: set_cookie('autoplay', 'off');\">Turn Autoplay OFF</a><br>Play videos when "Play" is clicked<br><hr>"; }elseif ($_COOKIE['autoplay'] === 'off'){ echo "<a href=\"javascript: set_cookie('autoplay', 'on');\">Turn Autoplay ON</a><br>Plays Videos Automatically<br><hr>"; } Link to comment https://forums.phpfreaks.com/topic/141927-if-else-is-driving-me-insane/ Share on other sites More sharing options...
Mchl Posted January 22, 2009 Share Posted January 22, 2009 'can't get this if else to work' is pretty vague explanation post more details Link to comment https://forums.phpfreaks.com/topic/141927-if-else-is-driving-me-insane/#findComment-743116 Share on other sites More sharing options...
landavia Posted January 22, 2009 Share Posted January 22, 2009 line 10.. (point 2 "PLAY") echo "<a href=\"javascript: set_cookie('autoplay', 'off');\">Turn Autoplay OFF</a><br>Play videos when "Play" is clicked<br><hr>"; u should type echo "<a href=\"javascript: set_cookie('autoplay', 'off');\">Turn Autoplay OFF</a><br>Play videos when \"Play\" is clicked<br><hr>"; and the repair are <? if (isset($_COOKIE['autoplay'])) { echo ""; }else{ //if (isset($_COOKIE['autoplay'])) echo "<a href=\"javascript: set_cookie('autoplay', 'on');\">Turn Autoplay ON</a><br>Plays Videos Automatically<br><hr>"; }//else if (isset($_COOKIE['autoplay'])) if ($_COOKIE['autoplay'] === 'on'){ echo "<a href=\"javascript: set_cookie('autoplay', 'off');\">Turn Autoplay OFF</a><br>Play videos when \"Play\" is clicked<br><hr>"; }elseif ($_COOKIE['autoplay'] === 'off'){ //if ($_COOKIE['autoplay'] === 'on'){ echo "<a href=\"javascript: set_cookie('autoplay', 'on');\">Turn Autoplay ON</a><br>Plays Videos Automatically<br><hr>"; }//elseif ($_COOKIE['autoplay'] === 'off') ?> Link to comment https://forums.phpfreaks.com/topic/141927-if-else-is-driving-me-insane/#findComment-743117 Share on other sites More sharing options...
printf Posted January 22, 2009 Share Posted January 22, 2009 Your logic makes no sense... You first test if $_COOKIE['autoplay'] is set and if it is you echo nothing, then further down you ask if $_COOKIE['autoplay'] equals on or $_COOKIE['autoplay'] equals off echo some data. Wouldn't it be better to enclose those two if(s) on or off in the if ISSET $_COOKIE['autoplay']! Link to comment https://forums.phpfreaks.com/topic/141927-if-else-is-driving-me-insane/#findComment-743124 Share on other sites More sharing options...
dreamwest Posted January 22, 2009 Author Share Posted January 22, 2009 line 10.. (point 2 "PLAY") echo "<a href=\"javascript: set_cookie('autoplay', 'off');\">Turn Autoplay OFF</a><br>Play videos when "Play" is clicked<br><hr>"; u should type echo "<a href=\"javascript: set_cookie('autoplay', 'off');\">Turn Autoplay OFF</a><br>Play videos when \"Play\" is clicked<br><hr>"; and the repair are <? if (isset($_COOKIE['autoplay'])) { echo ""; }else{ //if (isset($_COOKIE['autoplay'])) echo "<a href=\"javascript: set_cookie('autoplay', 'on');\">Turn Autoplay ON</a><br>Plays Videos Automatically<br><hr>"; }//else if (isset($_COOKIE['autoplay'])) if ($_COOKIE['autoplay'] === 'on'){ echo "<a href=\"javascript: set_cookie('autoplay', 'off');\">Turn Autoplay OFF</a><br>Play videos when \"Play\" is clicked<br><hr>"; }elseif ($_COOKIE['autoplay'] === 'off'){ //if ($_COOKIE['autoplay'] === 'on'){ echo "<a href=\"javascript: set_cookie('autoplay', 'on');\">Turn Autoplay ON</a><br>Plays Videos Automatically<br><hr>"; }//elseif ($_COOKIE['autoplay'] === 'off') ?> WHOOHOO!! Works ....Thanks Your logic makes no sense... You first test if $_COOKIE['autoplay'] is set and if it is you echo nothing, then further down you ask if $_COOKIE['autoplay'] equals on or $_COOKIE['autoplay'] equals off echo some data. Wouldn't it be better to enclose those two if(s) on or off in the if ISSET $_COOKIE['autoplay']! The first "if $_COOKIE['autoplay']" is for when theres no cookie, the rest of the script is for when they have a cookie either on or off. But i can see your point.. Link to comment https://forums.phpfreaks.com/topic/141927-if-else-is-driving-me-insane/#findComment-743134 Share on other sites More sharing options...
landavia Posted January 22, 2009 Share Posted January 22, 2009 err.. just because PLAY ur script not work? what editor u use.. I use Crimson Editor.. perhaps that's help you. btw.. you should use comment a lot.. since you will handle many things & human brain have their limit Link to comment https://forums.phpfreaks.com/topic/141927-if-else-is-driving-me-insane/#findComment-743142 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.