Page 1 of 1
PHP Switch not working
Posted: Sun Jul 24, 2011 9:03 pm
by 4cpukid
I have this command that in the URL bar if it reads <<<<>>>>/?view=old - it will view old.php but no matter what the case is all i see is MAIN. I pasted the code below Thanks in advance.
Code: Select all
<?php
// =========================DO NOT ALTER ANYTHING BELOW THIS LINE========================
$view = $_GET['view'];
if ($view=="") { $view = "main"; }
switch($view){
case "main":
@include('news/main.php');
break;
case "new":
$new = file_get_contents('http://cp.cioffitech.com/files/news/new.php');
echo $new;
break;
case "old":
$old = file_get_contents('http://cp.cioffitech.com/files/news/old.php');
echo $old;
break;
case "all":
$all = file_get_contents('http://cp.cioffitech.com/files/news/all.php');
echo $all;
break;
}
?>
Re: PHP Switch not working
Posted: Sun Jul 24, 2011 10:17 pm
by Jonah Bron
Is that all the code? Is there anything else that could affect it? Try removing the if clause. Are you sure you entered in the URL query string (?view=old) correctly?
Re: PHP Switch not working
Posted: Mon Jul 25, 2011 1:51 am
by kaydeveloper
I think the code which you have provided is completely perfect but you need to be sure that are you really passing the view=old in the URL?
Re: PHP Switch not working
Posted: Mon Jul 25, 2011 12:00 pm
by 4cpukid
Heres the page that uses this file:
Code: Select all
<?php
session_start(); // start session cookies (otherwise won't remember login between pages)
require("../includes/config.php");
require("../includes/Database.singleton.php");
require("../includes/Login.singleton.php");
// create initial singleton database connection and connect
$db = Database::obtain(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
$db->connect();
// create login singleton object
$login = Login::obtain();
// force a user login
$login->hard(2);
?>
<!DOCTYPE html>
<html>
<head>
<title>Access CP - Admin - Home</title>
<style>
#errorbar {
background-color: #770000;
color: #ffffff;
text-align: center;
font-size: 9pt;
margin: auto;
}
</style>
<link rel="stylesheet" href="main.css" type="text/css">
<script src="http://www.cioffitech.com/ct/c/div.js"></script>
</head>
<body>
<div class="f_container">
<div class="f_header">
<?php require('includes/header.inc.php'); ?>
</div>
<div class="f_menu">
<?php require('includes/menu.inc.php'); ?>
</div>
<div class="f_body">
<span align="center" id="errorbar">ATTENTION: We are experiancing some issues with our news feed and the THREE NEW CONTROL BUTTONS at thee bottom of the page are not functioning.</span><br /><br />
<?php
/* News and Updates of the Control Panel are kept and feed through the CioffiTech Server. DO NOT TOUCH THIS LINE OF CODE! */
/* @include('../../sd/cp/files/news.php'); */
/* echo implode(file("http://http://cp.cioffitech.com/files/news.php")); */
$newsfeed = file_get_contents('http://cp.cioffitech.com/files/news.php');
echo $newsfeed;
?>
</div>
<div class="f_footer">
<?php require('includes/footer.inc.php'); ?>
</div>
</div>
</body>
</html>
Re: PHP Switch not working
Posted: Mon Jul 25, 2011 8:35 pm
by Jonah Bron
Is it one of the includes? Which one?
Re: PHP Switch not working
Posted: Mon Jul 25, 2011 8:43 pm
by 4cpukid
4cpukid wrote:Heres the page that uses this file:
Code: Select all
<?php
session_start(); // start session cookies (otherwise won't remember login between pages)
require("../includes/config.php");
require("../includes/Database.singleton.php");
require("../includes/Login.singleton.php");
// create initial singleton database connection and connect
$db = Database::obtain(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
$db->connect();
// create login singleton object
$login = Login::obtain();
// force a user login
$login->hard(2);
?>
<!DOCTYPE html>
<html>
<head>
<title>Access CP - Admin - Home</title>
<style>
#errorbar {
background-color: #770000;
color: #ffffff;
text-align: center;
font-size: 9pt;
margin: auto;
}
</style>
<link rel="stylesheet" href="main.css" type="text/css">
<script src="http://www.cioffitech.com/ct/c/div.js"></script>
</head>
<body>
<div class="f_container">
<div class="f_header">
<?php require('includes/header.inc.php'); ?>
</div>
<div class="f_menu">
<?php require('includes/menu.inc.php'); ?>
</div>
<div class="f_body">
<span align="center" id="errorbar">ATTENTION: We are experiancing some issues with our news feed and the THREE NEW CONTROL BUTTONS at thee bottom of the page are not functioning.</span><br /><br />
<?php
/* News and Updates of the Control Panel are kept and feed through the CioffiTech Server. DO NOT TOUCH THIS LINE OF CODE! */
/* @include('../../sd/cp/files/news.php'); */
/* echo implode(file("http://http://cp.cioffitech.com/files/news.php")); */
$newsfeed = file_get_contents('http://cp.cioffitech.com/files/news.php');
echo $newsfeed;
?>
</div>
<div class="f_footer">
<?php require('includes/footer.inc.php'); ?>
</div>
</div>
</body>
</html>
------Sorry about that - Its the '$newsfeed'.--------