Jump to content

[SOLVED] PHP Switch just not working


someguy9

Recommended Posts


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>

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?


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>";


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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.