soycharliente Posted December 3, 2007 Share Posted December 3, 2007 You have a random "; break" at the bottom of your code. Maybe that's it. It looks fine to me other than that. The code I gave you had no errors in it so if you want some more results, I'd suggest actually telling us what it's doing and what it is supposed to be doing. I have Content.php <? $page = $_GET['page']; print "page: ".$page; switch($page) { case 'home': include('home.php'); break; case 'signup': include('register.php'); break; case 'video': include('video.php'); break; case 'contact': include('contact.php'); break; case 'videosort': include('videosort.php'); break; case 'archive': include('archive.php'); break; case 'search': include('search.php'); break; case 'games': include('game.php'); break; case 'test1': include('test.php'); break; case '360news': include('news.php'); break; case 'addcomment': include('addcomment.php'); break; default: include('home.php'); ; break; } ?> and index.php in just a snipplet (TOP) <?php include "./XXXXX.php"; $curdir = getcwd (); chdir('forum'); require_once('forum/global.php'); chdir ($curdir); $page = $_GET ; $XXXX= mysql_query("SELECT * from videos where id = '$_GET[XX]'"); $video = mysql_fetch_array($XXXX); $gamenfo = htmlspecialchars($_GET[info]); if ($vbulletin->userinfo['usergroupid'] == '6' ) { // include lastRSS library include './lastRSS.php'; // create lastRSS object $rss = new lastRSS; // setup transparent cache $rss->items_limit = 6; $rss->cache_dir = './cache'; $rss->cache_time = 120; ?> (then later) <div class="left"> <? include './content.php'; ?> </div> Quote Link to comment https://forums.phpfreaks.com/topic/79905-solved-php-switch-just-not-working/page/2/#findComment-405459 Share on other sites More sharing options...
someguy9 Posted December 4, 2007 Author Share Posted December 4, 2007 It looks as if only numbers are going through my $_GET Page, and it cuts anything off after it... i dont understand why it's doing this Quote Link to comment https://forums.phpfreaks.com/topic/79905-solved-php-switch-just-not-working/page/2/#findComment-405617 Share on other sites More sharing options...
btherl Posted December 4, 2007 Share Posted December 4, 2007 someguy, I suspect the problem is not content.php, but is in the code that executes before content.php. Can you add this to the absolute top of index.php print "index.php page = " . $page . "<br>"; And change your print inside content.php to print "content.php page = " . $page . "<br>"; Are the values the same? Quote Link to comment https://forums.phpfreaks.com/topic/79905-solved-php-switch-just-not-working/page/2/#findComment-405620 Share on other sites More sharing options...
boo_lolly Posted December 4, 2007 Share Posted December 4, 2007 what does your URL look like when you try processing this switch function? have you tried entering in your own values to test it? such as www.somesite.com/?page=someval Quote Link to comment https://forums.phpfreaks.com/topic/79905-solved-php-switch-just-not-working/page/2/#findComment-405623 Share on other sites More sharing options...
someguy9 Posted December 4, 2007 Author Share Posted December 4, 2007 someguy, I suspect the problem is not content.php, but is in the code that executes before content.php. Can you add this to the absolute top of index.php print "index.php page = " . $page . "<br>"; And change your print inside content.php to print "content.php page = " . $page . "<br>"; Are the values the same? I put it right below where i get the $page for the page in total and it still gets the same values <?php include "./config.php"; $curdir = getcwd (); chdir('forum'); require_once('forum/global.php'); chdir ($curdir); $page = "$_GET "; print "index.php page = " . $page . "<br>"; Quote Link to comment https://forums.phpfreaks.com/topic/79905-solved-php-switch-just-not-working/page/2/#findComment-405633 Share on other sites More sharing options...
btherl Posted December 4, 2007 Share Posted December 4, 2007 You'll need to put it at the top. Since $page is not available at the very top, you can do this instead. print "index.php page = " . $_GET['page'] . "<br>"; That must go before include './config.php' ; Quote Link to comment https://forums.phpfreaks.com/topic/79905-solved-php-switch-just-not-working/page/2/#findComment-405637 Share on other sites More sharing options...
someguy9 Posted December 4, 2007 Author Share Posted December 4, 2007 it works above my forum intergration code <?php include "./config.php"; $curdir = getcwd (); chdir('forum'); require_once('forum/global.php'); chdir ($curdir); print "index.php page = " . $_GET['page'] . "<br>"; $page = "$_GET "; but below it, it does the letter thing Quote Link to comment https://forums.phpfreaks.com/topic/79905-solved-php-switch-just-not-working/page/2/#findComment-405646 Share on other sites More sharing options...
phpSensei Posted December 4, 2007 Share Posted December 4, 2007 whats $page = "$_GET "; ? make it $_GET['page'] without quotes. Quote Link to comment https://forums.phpfreaks.com/topic/79905-solved-php-switch-just-not-working/page/2/#findComment-405650 Share on other sites More sharing options...
btherl Posted December 4, 2007 Share Posted December 4, 2007 Ok, so the problem is that the forum integration code is altering $_GET['page']. You can work around that by keeping a copy. For example $get_page_copy = $_GET['page'];# <-- at the very top Then inside content.php: $page = $get_page_copy; Better would be to find out why $_GET is being altered.. there's probably a good reason. Quote Link to comment https://forums.phpfreaks.com/topic/79905-solved-php-switch-just-not-working/page/2/#findComment-405651 Share on other sites More sharing options...
phpSensei Posted December 4, 2007 Share Posted December 4, 2007 Cant you just change it to like "p" instead of "page" ? Quote Link to comment https://forums.phpfreaks.com/topic/79905-solved-php-switch-just-not-working/page/2/#findComment-405653 Share on other sites More sharing options...
someguy9 Posted December 4, 2007 Author Share Posted December 4, 2007 changing the name works! I wonder why page is taken by the forum intergration Quote Link to comment https://forums.phpfreaks.com/topic/79905-solved-php-switch-just-not-working/page/2/#findComment-405655 Share on other sites More sharing options...
phpSensei Posted December 4, 2007 Share Posted December 4, 2007 changing the name works! I wonder why page is taken by the forum intergration YaY! Finally, its about time haha. Please click Topic Solved as soon as you can. Quote Link to comment https://forums.phpfreaks.com/topic/79905-solved-php-switch-just-not-working/page/2/#findComment-405658 Share on other sites More sharing options...
someguy9 Posted December 4, 2007 Author Share Posted December 4, 2007 this is wonderful! Quote Link to comment https://forums.phpfreaks.com/topic/79905-solved-php-switch-just-not-working/page/2/#findComment-405662 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.