LemonInflux Posted July 28, 2008 Share Posted July 28, 2008 works for me I think it's solved ---------------- Now playing: Enter Shikari - Adieu via FoxyTunes Quote Link to comment https://forums.phpfreaks.com/topic/116819-solved-what-is-going-on-here-sessions-variables/page/2/#findComment-601443 Share on other sites More sharing options...
crazylegsmurphy Posted July 28, 2008 Author Share Posted July 28, 2008 Really? Cause I'm getting the same thing over and over again...and it's also broken in IE 7. Quote Link to comment https://forums.phpfreaks.com/topic/116819-solved-what-is-going-on-here-sessions-variables/page/2/#findComment-601450 Share on other sites More sharing options...
crazylegsmurphy Posted July 28, 2008 Author Share Posted July 28, 2008 I'm getting the same in IE7, FF, and Safari. When you click "Autumn" it changes just fine, but then if you click the next page it defaults back to "summer.css" as you can see in the source file. This is how I ultimately check which css file it's loading. Quote Link to comment https://forums.phpfreaks.com/topic/116819-solved-what-is-going-on-here-sessions-variables/page/2/#findComment-601459 Share on other sites More sharing options...
LemonInflux Posted July 28, 2008 Share Posted July 28, 2008 Ooooh, I see! Right, so you want it to be cross-page compatible? Right then, you have 2 options: - Either change your links to add the $_GET extention. Ooor... <?php session_start(); $seasons = array ( 'spring' => array('March', 'April', 'May'), 'summer' => array('June', 'July', 'August'), 'autumn' => array('September', 'October', 'November'), 'december' => array('December', 'January', 'February') ); if(isset($_GET['css']) && array_key_exists($_GET['css'], $seasons)) { $css = $_GET['css']; $_SESSION['css'] = $_GET['css']; } elseif(isset($_SESSION['css'] && array_key_exists($_SESSION['css'], $seasons)) { $css = $_SESSION['css']; } else { foreach($seasons as $season) { if(in_array(date('F'), $season)) { $css = $season; $_SESSION['css'] = $season; } } } EDIT: Made a small change ---------------- Now playing: Enter Shikari - Closing via FoxyTunes Quote Link to comment https://forums.phpfreaks.com/topic/116819-solved-what-is-going-on-here-sessions-variables/page/2/#findComment-601463 Share on other sites More sharing options...
samshel Posted July 28, 2008 Share Posted July 28, 2008 if (!isset($_GET['css'])) { if ($date >= 4 && $date <= 5 || $css == 'spring'){ ?> <link rel="stylesheet" href="/_stylesheets/spring.css" type="text/css" media="screen" /> <? } elseif ($date >= 6 && $date <= 8 || $css == 'summer') { ?> <link rel="stylesheet" href="/_stylesheets/summer.css" type="text/css" media="screen" /> if $_GET['css'] is not set and month is between 6 & 8 ( which it is actually as it is July now), it will show summer as css..... Where is $css initialized? i cannot see it in the code of your first post. basically i think you should do something like this... <?php //remove this line from top.... //$_SESSION["css"] = ($_GET['css']); //try following code //First priority, check if $_GET is set $css = "default"; if(isset($_GET['css']) && in_array($_GET['css'], array('spring', 'summer', 'autumn', 'winter'))) { $css = $_GET['css']; $_SESSION["css"] = $css; } // Second priority from $_SESSION else if(isset($_SESSION["css"])) { $css = $_SESSION['css']; } //third priority css by date else { $date = date("n"); if ($date >= 4 && $date <= 5){ $css = "spring";} elseif ($date >= 6 && $date <= { $css = "summer";} elseif ($date >= 9 && $date <= 10){ $css = "autumn";} elseif ($date >= 11 || $date <= 5){ $css = "winter";} else $css = "screen"; } ?> <link rel="stylesheet" href="/_stylesheets/<?php echo $css; ?>.css" type="text/css" media="screen" /> Quote Link to comment https://forums.phpfreaks.com/topic/116819-solved-what-is-going-on-here-sessions-variables/page/2/#findComment-601469 Share on other sites More sharing options...
crazylegsmurphy Posted July 28, 2008 Author Share Posted July 28, 2008 ya ya, it has to keep the selection so it's like the user can say, "I would rather look at this whole site in winter pictures" if they wanted and not have to click it on every page. I don't think I can change all the links as there are way to many....but...the code you posted gives me the following error. Parse error: syntax error, unexpected T_BOOLEAN_AND, expecting ',' or ')' in /home/mmmyeahc/public_html/community/community.php on line 14 This is the code I have on the index.php page. <?php session_start(); $section='community'; $seasons = array ( 'spring' => array('March', 'April', 'May'), 'summer' => array('June', 'July', 'August'), 'autumn' => array('September', 'October', 'November'), 'december' => array('December', 'January', 'February') ); if(isset($_GET['css']) && array_key_exists($_GET['css'], $seasons)) { $css = $_GET['css']; } elseif(isset($_SESSION['css'] && array_key_exists($_SESSION['css'], $seasons)) { $css = $_SESSION['css']; } else { foreach($seasons as $season) { if(in_array(date('F'), $season)) { $css = $season; $_SESSION['css'] = $css; } } } include('../_includes/top.php'); ?> <div id="content-preview"> <p class="italic">Engage, Inspire...</p> <p><a class="more" href="community.php" title="community">More...</a></p> </div> <?PHP include('../_includes/bottom.php'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/116819-solved-what-is-going-on-here-sessions-variables/page/2/#findComment-601470 Share on other sites More sharing options...
samshel Posted July 28, 2008 Share Posted July 28, 2008 complete "(" for isset($_SESSION['css'] on line 14 Quote Link to comment https://forums.phpfreaks.com/topic/116819-solved-what-is-going-on-here-sessions-variables/page/2/#findComment-601474 Share on other sites More sharing options...
crazylegsmurphy Posted July 28, 2008 Author Share Posted July 28, 2008 What a min..... Samshel....I think you may have gotten it...but I need to look give it a test. Quote Link to comment https://forums.phpfreaks.com/topic/116819-solved-what-is-going-on-here-sessions-variables/page/2/#findComment-601476 Share on other sites More sharing options...
LemonInflux Posted July 28, 2008 Share Posted July 28, 2008 Edit: haha, I see. Sorry :S It was hastily done ---------------- Now playing: Enter Shikari - Closing via FoxyTunes Quote Link to comment https://forums.phpfreaks.com/topic/116819-solved-what-is-going-on-here-sessions-variables/page/2/#findComment-601480 Share on other sites More sharing options...
LemonInflux Posted July 28, 2008 Share Posted July 28, 2008 Yes sorry, I understand now. My keyboard is being a bit weird, and the backspace gets stuck. I must've clicked there by accident, because it's fine on my local server I hope that's the only error, haha ---------------- Now playing: Enter Shikari - Closing via FoxyTunes Quote Link to comment https://forums.phpfreaks.com/topic/116819-solved-what-is-going-on-here-sessions-variables/page/2/#findComment-601481 Share on other sites More sharing options...
crazylegsmurphy Posted July 28, 2008 Author Share Posted July 28, 2008 Ya, that's the one I am trying. The community section should stay now http://www.mmmyeah.com/community/ If this is the case...then sir....you have made my week! Lemon...I don't even wanna know why you have a sticky keyboard! Quote Link to comment https://forums.phpfreaks.com/topic/116819-solved-what-is-going-on-here-sessions-variables/page/2/#findComment-601482 Share on other sites More sharing options...
LemonInflux Posted July 28, 2008 Share Posted July 28, 2008 As hilarious as this may sound, I spilt lemon juice in it (I say 'I', I mean my baby cousin). Really, don't ask. She has a thing for lemons.. ---------------- Now playing: Enter Shikari - Closing via FoxyTunes Quote Link to comment https://forums.phpfreaks.com/topic/116819-solved-what-is-going-on-here-sessions-variables/page/2/#findComment-601487 Share on other sites More sharing options...
LemonInflux Posted July 28, 2008 Share Posted July 28, 2008 It works for me Oh, and delete the echo line, it's displaying 'autumn' in the top left corner EDIT: Well, actually, the session's season value ---------------- Now playing: Enter Shikari - Closing via FoxyTunes Quote Link to comment https://forums.phpfreaks.com/topic/116819-solved-what-is-going-on-here-sessions-variables/page/2/#findComment-601490 Share on other sites More sharing options...
crazylegsmurphy Posted July 28, 2008 Author Share Posted July 28, 2008 Hmmm... it seems to be working, and it seems to default back to the summer when I come back to the page in IE... but not in FF. Just for my own knowledge...do all the browsers need to be closed to restart a session? Meaning if I have 3 FF browsers open, will it keep the session until they're all closed? Quote Link to comment https://forums.phpfreaks.com/topic/116819-solved-what-is-going-on-here-sessions-variables/page/2/#findComment-601491 Share on other sites More sharing options...
LemonInflux Posted July 28, 2008 Share Posted July 28, 2008 I think so, yes. Because they're all keeping the same cookies/sessions etc. Close them all and find out ---------------- Now playing: Enter Shikari - Closing via FoxyTunes Quote Link to comment https://forums.phpfreaks.com/topic/116819-solved-what-is-going-on-here-sessions-variables/page/2/#findComment-601494 Share on other sites More sharing options...
crazylegsmurphy Posted July 28, 2008 Author Share Posted July 28, 2008 Ahh...ok then. Cool! Well everyone...I'm not so cranky now! I want to thank everyone for their help getting this going. I truly appreciate all the effort put in by all especially LemonInFlux and samshel!! I suppose I can call this one solved! And I suppose I can actually sleep now! Quote Link to comment https://forums.phpfreaks.com/topic/116819-solved-what-is-going-on-here-sessions-variables/page/2/#findComment-601501 Share on other sites More sharing options...
LemonInflux Posted July 28, 2008 Share Posted July 28, 2008 Haha, no problem. I always get a geeky sense of accomplishment when I solve a problem Now quick, click the topic solved button before hundreds of people start shouting ---------------- Now playing: Enter Shikari - Kickin' Back On The Surface Of Your Cheeks via FoxyTunes Quote Link to comment https://forums.phpfreaks.com/topic/116819-solved-what-is-going-on-here-sessions-variables/page/2/#findComment-601502 Share on other sites More sharing options...
crazylegsmurphy Posted July 28, 2008 Author Share Posted July 28, 2008 You guys don't even know how much it helped. This was the last project I had to do and then I have a three week vacation....but more importantly, I am moving out of this place in two days so I wouldn't be able to finish this site for the client until I got back...and the deadline in Tuesday. So, by the skin of my teeth you guys saved my butt! Quote Link to comment https://forums.phpfreaks.com/topic/116819-solved-what-is-going-on-here-sessions-variables/page/2/#findComment-601506 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.