bloodgoat Posted March 4, 2009 Share Posted March 4, 2009 This all works just fine one host but it doesn't work at all on another. No errors or anything, it just doesn't do it's function. It sits on the defined home page as though nothing else has been set, even when it has. (and before you ask, yes, I am updating the paths for the new server lol...) if(!isset($p) && !isset($myblog) && !isset($portfolio) && !isset($music) && !isset($mynews)) { $table = $homecon; $content = file_get_contents("$pathcont/home.html"); } elseif(isset($p)) { $table = $elsecon; $content = file_get_contents("$pathcont/$p.html"); } elseif(isset($myblog)) { $imghead = "bhead.png"; $head = file_get_contents("$pathblog/head.html"); $table = $portcon; $content = file_get_contents("$pathblog/$myblog.html"); } elseif(isset($portfolio)) { $imghead = "phead.png"; $head = file_get_contents("$pathport/head.html"); $table = $portcon; $content = file_get_contents("$pathport/$portfolio.html"); } elseif(isset($music)) { require("$pathmusic/music.php"); $imghead = "mhead.png"; $head = $display; $table = $portcon; $content = file_get_contents("$pathmusic/$music.html"); } elseif(isset($mynews)) { $imghead = "nhead.png"; $head = file_get_contents("$pathnews/head.html"); $table = $portcon; $content = file_get_contents("$pathnews/$mynews.html"); } Anything wrong with it? One more thing... I'm variable swapping in my URLs to keep the addresses short and trim (would rather look at: ?blog=007 than ?p=blogs&blog=007 or ?p=blogs/007 for example) and also to pull separate template codes ($table / $imghead) for sub-navigation swapping but naturally this leads to big heap of code. Is there any way to trim the above to something shorter while still retaining all functions? Quote Link to comment https://forums.phpfreaks.com/topic/147984-solved-errors-in-this-file_get_contents-code/ Share on other sites More sharing options...
wildteen88 Posted March 4, 2009 Share Posted March 4, 2009 Juding by what your urls are. Your code relies on an outdatted setting called register_globals (which has been disabled since 2002 and is soon to be removed completely as of php6). You should update your code so it doesn't rely on this setting. Doing this allows your code to be more portable and improve security. To help suggest what to do you should post your code inful. Quote Link to comment https://forums.phpfreaks.com/topic/147984-solved-errors-in-this-file_get_contents-code/#findComment-776732 Share on other sites More sharing options...
bloodgoat Posted March 4, 2009 Author Share Posted March 4, 2009 My entire get_contents.php file: <?php include("cont.php"); require("titles.php"); $fp = "/path/to/site/lol"; $pathcont = "$fp/contents"; $pathblog = "$fp/blogs"; $pathport = "$fp/portfolio"; $pathmusic = "$fp/music"; $pathnews = "$fp/news"; if(!isset($p) && !isset($myblog) && !isset($portfolio) && !isset($music) && !isset($mynews)) { $table = $homecon; $content = file_get_contents("$pathcont/home.html"); } elseif(isset($p)) { $table = $elsecon; $content = file_get_contents("$pathcont/$p.html"); } elseif(isset($myblog)) { $imghead = "bhead.png"; $head = file_get_contents("$pathblog/head.html"); $table = $portcon; $content = file_get_contents("$pathblog/$myblog.html"); } elseif(isset($portfolio)) { $imghead = "phead.png"; $head = file_get_contents("$pathport/head.html"); $table = $portcon; $content = file_get_contents("$pathport/$portfolio.html"); } elseif(isset($music)) { require("$pathmusic/music.php"); $imghead = "mhead.png"; $head = $display; $table = $portcon; $content = file_get_contents("$pathmusic/$music.html"); } elseif(isset($mynews)) { $imghead = "nhead.png"; $head = file_get_contents("$pathnews/head.html"); $table = $portcon; $content = file_get_contents("$pathnews/$mynews.html"); } ?> cont.php is where I store the templates I call through $table and titles.php is just page titles. Quote Link to comment https://forums.phpfreaks.com/topic/147984-solved-errors-in-this-file_get_contents-code/#findComment-776781 Share on other sites More sharing options...
wildteen88 Posted March 4, 2009 Share Posted March 4, 2009 Umm by looks of it $p should be $_GET['p']; $myblog should be $_GET['myblog']; $portfolio should be $_GET['portfolio']; $musicshould be $_GET['music']; $mynews should be $_GET['mynews']; Quote Link to comment https://forums.phpfreaks.com/topic/147984-solved-errors-in-this-file_get_contents-code/#findComment-776785 Share on other sites More sharing options...
bloodgoat Posted March 4, 2009 Author Share Posted March 4, 2009 Umm by looks of it $p should be $_GET['p']; $myblog should be $_GET['myblog']; $portfolio should be $_GET['portfolio']; $musicshould be $_GET['music']; $mynews should be $_GET['mynews']; Could you pull one of my statements and swap them out so I know which ones to switch exactly? Just by reading that I'm thinking you mean like this: elseif(isset($myblog)) { $imghead = "bhead.png"; $head = file_get_contents("$pathblog/head.html"); $table = $portcon; $content = file_get_contents("$pathblog/$_GET['myblog'].html"); } But I want to make sure. Quote Link to comment https://forums.phpfreaks.com/topic/147984-solved-errors-in-this-file_get_contents-code/#findComment-776795 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.