Results from the most recent live auction are here .
21 members in the live chat room. Join Chat !
05-28-2006, 03:40 PM
· #1 NamePros Regular
Name: Edward Marriner
Location: England :D
Join Date: Apr 2005
Posts: 838
NP$: 51.85 (
Donate )
Quick 5 min thing. getting blank page
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 Code:
<?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
__________________
Leeds united football club
05-28-2006, 03:55 PM
· #2 Eating Pie
Name: Steve
Location: Canada
Join Date: Nov 2004
Posts: 2,284
NP$: 91.30 (
Donate )
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 Code:
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
05-28-2006, 04:30 PM
· #3 while ($awake){ code(); }
Name: Eric
Location: Kentucky
Join Date: Mar 2005
Posts: 4,268
NP$: 1152.00 (
Donate )
Yes, agreed with iNod. Uses switch()'s man!
And since I'm in a good mood, for once, something like below:
PHP Code:
<?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;
}
}
?>
05-28-2006, 05:48 PM
· #4 NamePros Regular
Location: mysitememberships.com
Join Date: Jul 2005
Posts: 925
NP$: 4800.90 (
Donate )
well the reason ur getting a blank page is because ur error "else" case is wrong. you have this:
PHP Code:
}else(
echo "Error, do is empty or is somthing its not ment to be, do = '$do' " ;
}
it should be this:
PHP Code:
}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 Code:
$_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.
05-29-2006, 02:56 AM
· #5 NamePros Regular
Name: Edward Marriner
Location: England :D
Join Date: Apr 2005
Posts: 838
NP$: 51.85 (
Donate )
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.
__________________
Leeds united football club
05-29-2006, 07:31 PM
· #6 NamePros Regular
Location: mysitememberships.com
Join Date: Jul 2005
Posts: 925
NP$: 4800.90 (
Donate )
lol NP$ received thnx man!
glad to be of service!
05-30-2006, 09:47 AM
· #7 while ($awake){ code(); }
Name: Eric
Location: Kentucky
Join Date: Mar 2005
Posts: 4,268
NP$: 1152.00 (
Donate )
No problem. And thanks for the NP$, although it wasn't needed
Eric
05-30-2006, 10:25 AM
· #8 Soon to be RICHdoggie!
Name: Tom
Location: UK
Join Date: Jan 2005
Posts: 2,390
NP$: 300.50 (
Donate )
Originally Posted by nasaboy007 well the reason ur getting a blank page is because ur error "else" case is wrong. you have this:
PHP Code:
}else(
echo "Error, do is empty or is somthing its not ment to be, do = '$do' " ;
}
it should be this:
PHP Code:
}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 Code:
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.
Quote:
also, in ur first couple of if statements, you have:
PHP Code:
$_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!
05-30-2006, 11:03 AM
· #9 while ($awake){ code(); }
Name: Eric
Location: Kentucky
Join Date: Mar 2005
Posts: 4,268
NP$: 1152.00 (
Donate )
Using either OR or || is the same. Just as AND or &&.
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off