MartinBurrito Posted March 20, 2021 Share Posted March 20, 2021 Hi there. I hope you guys can help :) This works on local host but once online it fails with "PHP Warning: session_start(): Cannot start session when headers already sent in /home/martinsb/public_html/switcher/switch.php on line 10" Here is the nav part <!---new code added for style switcher--> Style is set to <?php echo $_SESSION["msg"];?><br/> <a class="<?php echo $_SESSION['look0'];?>" href="switcher/switch.php?set=default">Default</a> <a class="<?php echo $_SESSION['look1'];?>" href="switcher/switch.php?set=ada">ADA</a> <a class="<?php echo $_SESSION['look2'];?>" href="switcher/switch.php?set=burrito">Burrito</a><br/> <div style="font-size:12px; padding-top:8px; padding-bottom:10px;"><?php echo $_SESSION["why"];?></div> <!--end switcher--> Here is the switcher.php <?php $part= $_SERVER['HTTP_REFERER']; $path_parts = pathinfo($part); $result = $path_parts['basename']; session_start(); ?> <?php if( !isset($_GET['set'])){ echo ""; } elseif ($_GET['set']=='default') { $_SESSION["css"]="css/mysite.css"; $_SESSION["msg"]="Default"; } elseif ($_GET['set']=='dark') { $_SESSION["css"]="css/darkstyles.css"; $_SESSION["msg"]="Dark"; } elseif($_GET['set']=='light') { $_SESSION["css"]="css/lightstyles.css"; $_SESSION["msg"]="Light"; } if ( !isset($_SESSION["css"]) ) {$_SESSION["css"]="css/mysite.css"; $_SESSION["msg"]="Default"; } ?> <?php // 301 Moved Permanently header("Location: ../$result", true, 301); exit(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/312337-css-switcher-works-local-but-not-online/ Share on other sites More sharing options...
requinix Posted March 20, 2021 Share Posted March 20, 2021 The error message says it's switch.php and that you're starting the session on line 10. That doesn't match up with what you've posted. Quote Link to comment https://forums.phpfreaks.com/topic/312337-css-switcher-works-local-but-not-online/#findComment-1585234 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.