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>
Link to comment
Share on other sites

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?

Link to comment
Share on other sites


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

Link to comment
Share on other sites


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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.