NameSilo

Quick 5 min thing. getting blank page

Spacemail by SpaceshipSpacemail by Spaceship
Watch

edmarriner

Established Member
Impact
4
Hi,

Im getting a blank page with no errors on.

The php code im using is this and i cant see anythink wrong, any deas, prob me just being stupid and missing out somthing simple.

PHP:
<?php
  
if(
	$_POST['do'] == "" or $_GET['do'] == ""){
		 $_GET['do'] == "home";
}
if(
	$_POST['do'] == "search" or $_GET['dosearch'] == "yes"){
		 $subaction = "search"; $dosearch = "yes"; include("./search.php"); 
}elseif(
	$_GET['do'] == "TV_news"){
		 $category = "1"; $template = "tv"; include("./show_news.php");
}elseif(
	$_GET['do'] == "TV_sport"){
		 $category = "2"; $template = "tv"; include("./show_news.php");
}elseif(
	$_GET['do'] == "TV_kids"){
		 $category = "3"; $template = "tv"; include("./show_news.php");
}elseif(
	$_GET['do'] == "TV_music"){
		 $category = "4"; $template = "tv"; include("./show_news.php");
}elseif(
	$_GET['do'] == "TV_moives"){
		 $category = "5"; $template = "tv"; include("./show_news.php");
}elseif(
	$_GET['do'] == "TV_general"){
		 $category = "6"; $template = "tv"; include("./show_news.php");
}elseif(
	$_GET['do'] == "home"){
		 $category = "100";  $template = "content"; include("./show_news.php");
}elseif(
	$_GET['do'] == "contact"){
		 $category = "101";  $template = "content"; include("./show_news.php");
}elseif(
	$_GET['do'] == "help"){
		 $category = "103";  $template = "content"; include("./show_news.php");
}elseif(
	$_GET['do'] == "submit"){
		 $category = "104";  $template = "content"; include("./show_news.php");
}elseif(
	$_GET['do'] == "tv"){
		 $category = "105";  $template = "content"; include("./show_news.php");
}elseif(
	$_GET['do'] == "a1d9m9i2n"){
		 echo"welcome back admin";
}else(
		 echo"Error, do is empty or is somthing its not ment to be, do = '$do' ";
}
?>

Any help will be a great help.

Thanks,

-ed
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable DomainsUnstoppable Domains
Hello,

First I would recommand you do this.

Remove all those if's and change them to switch and case

Example of switch and case
PHP:
switch ($i) {
case 0:
   echo "i equals 0";
   break;
case 1:
   echo "i equals 1";
   break;
case 2:
   echo "i equals 2";
   break;
default:
   echo "i is not equal to 0, 1 or 2";
}
(Copied from php.net :P)

Anyways.. I would recommand you use that instead of a bunch of if's. Give that a try.

- Steve
 
0
•••
Yes, agreed with iNod. Uses switch()'s man! :D And since I'm in a good mood, for once, something like below:

PHP:
<?php

if ($_POST['do'] == '' OR $_GET['do'] == '')
{
    $_GET['do'] == 'home';
}
else if ($_POST['do'] == 'search' or $_GET['dosearch'] == 'yes')
{
    $subaction = 'search';
    $dosearch = 'yes';
    include('./search.php');
}
else
{
    switch ($_GET['do'])
    {
        case 'TV_news':
            $category = '1';
            $template = 'tv';
            include('./show_news.php');
            break;
        case 'TV_sport':
            $category = '2';
            $template = 'tv';
            include('./show_news.php');
            break;
        case 'TV_kids':
            $category = '3';
            $template = 'tv';
            include('./show_news.php');
            break;
        case 'TV_music':
            $category = '4';
            $template = 'tv';
            include('./show_news.php');
            break;
        case 'TV_moives':
            $category = '5';
            $template = 'tv';
            include('./show_news.php');
            break;
        case 'TV_general':
            $category = '6';
            $template = 'tv';
            include('./show_news.php');
            break;
        case 'home':
            $category = '100';
            $template = 'content';
            include('./show_news.php');
            break;
        case 'contact':
            $category = '101';
            $template = 'content';
            include('./show_news.php');
            break;
        case 'help':
            $category = '103';
            $template = 'content';
            include('./show_news.php');
            break;
        case 'submit':
            $category = '104';
            $template = 'content';
            include('./show_news.php');
            break;
        case 'tv':
            $category = '105';
            $template = 'content';
            include('./show_news.php');
            break;
        case 'a1d9m9i2n':
            echo 'Welcome back admin';
            break;
        default:
            $category = '100';
            $template = 'content';
            include('./show_news.php');
            break;
    }
}

?>
 
0
•••
well the reason ur getting a blank page is because ur error "else" case is wrong. you have this:

PHP:
}else( 
         echo"Error, do is empty or is somthing its not ment to be, do = '$do' "; 
}

it should be this:

PHP:
}else{ 
         echo("Error, do is empty or is somthing its not ment to be, do = " . $do); 
}

notice the curly bracket open after the else rather than the open parenthesis. also, you have never define the variable $do. if u want it to echo $_GET['do'], then either write that out or put somewhere before in that code $do = $_GET['do'].

also, in ur first couple of if statements, you have:

PHP:
$_POST['do'] == "" or $_GET['do'] == ""

im not sure, but i dont know if u can use the word "or". i wud suggest using || (thats BAR BAR, shift+slashaboveenter) instead of or (just like && is used for and).

change all that and see if it works.
 
0
•••
We're glad that you're fond of this member, but please give some rep points to some other members before giving it to SecondVersion again.

We're glad that you're fond of this member, but please give some rep points to some other members before giving it to nasaboy007 again.

Ill send over some np because i cant give you any rep.
 
0
•••
lol NP$ received thnx man!

glad to be of service!
 
0
•••
No problem. And thanks for the NP$, although it wasn't needed ;)

Eric
 
0
•••
nasaboy007 said:
well the reason ur getting a blank page is because ur error "else" case is wrong. you have this:

PHP:
}else( 
         echo"Error, do is empty or is somthing its not ment to be, do = '$do' "; 
}

it should be this:

PHP:
}else{ 
         echo("Error, do is empty or is somthing its not ment to be, do = " . $do); 
}
Those shouldn't be needed, just putting a space inbetween the "echo" and the " "..." " should be necessary and also as long as there are double quotes " " " round something then you can just echo "$do" in the middle of a string.

What I can see is that you never set the variable "$do" to mean anything. Put this at the start of your code:

PHP:
if(isset($_POST['do']) || isset($_GET['do'])){
  $do = (isset($_POST['do'])) ? $_POST['do'] : $_GET['do'];
}
else{
  echo "No $do variable is set";
}

Now, every instance of $_GET['do'] and $_POST['do'] can be exchanged for $do.

also, in ur first couple of if statements, you have:

PHP:
$_POST['do'] == "" or $_GET['do'] == ""

im not sure, but i dont know if u can use the word "or". i wud suggest using || (thats BAR BAR, shift+slashaboveenter) instead of or (just like && is used for and).

I know that "OR" works, and therefore I think that "or" would work, but it is good practice to use "||" instead (don't ask me why, I just like it that way! :) )


Good luck with your code! :)
 
0
•••
Using either OR or || is the same. Just as AND or &&.
 
0
•••
Unstoppable Domains
Domain Recover
DomainEasy โ€” Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back