Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

I receive an error in PHP when there is no ?cat in the address but if it is there the error goes away

Posted on 2008-10-23
4
Medium Priority
?
177 Views
Last Modified: 2013-11-05
I'm working on a dynamic page in PHP and I want the page to display something different depending on the variable passed in using the GET Method.  However, if I do not have anything being passed in the URL, than I get an error like this
http://www.mybiblegames.com/settings.php
But if I do have something, i do not get an error like this
http://www.mybiblegames.com/settings.php?cat
and this
http://www.mybiblegames.com/settings.php?cat=Billing

Attached is the PHP code in charge o this
<? 
///////////////////////////////// Begin Dynamic Content /////////////////////////////////
 
if($_GET['cat']){
	switch($_GET['cat']){
		case "Profile":
			?> <!-- Profile Content -->
			
			This page will allow you to edit your profile.<br/>
			Things you will be able to edit include:<br/>
			Name, Location, Age, Favorite Bible Verse, Biography, Time Zone, Gender, Password, Website and Email.
			
			<?
			break;
		case "Billing":
			?> <!-- Billing Content -->
			
			From this page, the user can make a payment in order to renew their account.  They can also change their 'Billing Address' from here as well as their membership type.  They can choose to upgrade or downgrade their membership.  If they upgrade, accounts will be added, if downgraded, they choose.<br/><br/>
			
			<b>Membership Fee's</b><br/>
			<u>Single Member</u><br/>
			$4.95 a month or $50 a year<br/>
			<u>2 Members</u><br/>
			$8.77 a month or $85 a year<br/>
			<u>3 Members</u><br/>
			$12.95 a month or $130 a year<br/>
			<u>5 Members</u><br/>
			$19.95 a month or $200 a year<br/>
 
			
			<?
			break;
		case "Favorites":
			?> <!-- Favorites Content -->
			
			This page would show all the games which the user has set as their favorites.<br/><br/>
			On the pages which contain the flash games, the user's will be able to click a button that allows them to add that game as their favorite and those games will be displayed on both the 'Games' page and on the Index page (where the users are able to sort thru the games).<br/><br/>
			This page not only will allow the user to see what they have set as their favorite games, but it will also let them remove them.
			
			<?
			break;
		case "Friends":
			?> <!-- Friends Content -->
			
			This page would show all the people that the User has selected as 'Friends' from the site.<br/><br/>
			When someone goes to another person's profile, the user will be able to click a button to add that person as a 'Friend'.  On this page, it will show all the friends that the user has and also give them the ability to remove friends.
			
			<?
			break;
		
	}
} else {
	?> 
	Please click an item to the left to navigate thru the various settings.
	<?
}
 
 
///////////////////////////////// Ended Dynamic Content /////////////////////////////////
?>

Open in new window

0
Comment
Question by:davideo7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 4

Accepted Solution

by:
husker475 earned 2000 total points
ID: 22790354
Change
if($_GET['cat']){

to

if(isset($_GET['cat'])){
0
 
LVL 17

Expert Comment

by:psimation
ID: 22790373
that is not an "error", it's a NOTICE - turn off error_display, or only display errors and warnings.
0
 
LVL 82

Expert Comment

by:hielo
ID: 22790376
change:
if($_GET['cat']){ 
to:
if( isset($_GET['cat'])  && !empty($_GET['cat']) ) {

Open in new window

0
 

Author Closing Comment

by:davideo7
ID: 31509408
Thanks, that was the problem and I didn't even notice it!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question