Current location: Hot Scripts Forums » Programming Languages » PHP » I have a problem...


I have a problem...

Reply
  #1 (permalink)  
Old 03-19-04, 09:22 AM
ICE Flame ICE Flame is offline
Newbie Coder
 
Join Date: Mar 2004
Location: Israel
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy I have a problem...

Hello everybody...
I have a problem with my PHP application.
When I'm trying to activate my application, I get this error message:
Code:
Notice: Undefined index: act in c:\apache\htdocs\hpnet\admin_updates.php on line 18
Well, my 18th line in admin_updates.php is:
PHP Code:

switch ($_GET['act']) 

And I've already defined the variable 'act' - take a look at the 6th line:
PHP Code:

$act $_GET
What is the problem? Why am I getting this error message over and over?
Please help me.
Thank you
Reply With Quote
  #2 (permalink)  
Old 03-19-04, 09:50 AM
Infinite_Hackers's Avatar
Infinite_Hackers Infinite_Hackers is offline
Coding Addict
 
Join Date: Dec 2003
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
the $_GET[] is getting the value of a variable from a url, not a variable set in the script.. so if you go to..
admin_updates.php?act=set
__________________
New beta project: GFX-PRO.ATH.CX
Description: GFX-PRO a great new project that anyone can and setup in less then a minute. [ More info ]
Website: http://gfx-pro.ath.cx
Status: Online
http://gfx-pro.ath.cx/sig.png
Reply With Quote
  #3 (permalink)  
Old 03-19-04, 10:13 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
$_GET is a predefined global array !
in your code you are creating another array called $act which has the same values in $_GET..

and your switch() will never return anything but the default value or NULL! because $_GET['act'] is null unless your URL looks like this:
admin_updates.php?act=VALUE
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #4 (permalink)  
Old 03-20-04, 01:40 PM
ICE Flame ICE Flame is offline
Newbie Coder
 
Join Date: Mar 2004
Location: Israel
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks, but...

This is my switch() code:
PHP Code:

switch ($_GET['act'])

{
case 
"add":
include(
'add.tpl');
break;
default:
include(
'index.tpl');

The weird thing is the code works grate, the default and the "add" case, but the error message still appears - but only when I'm trying to activate the default case.
Please explain me what to do.
Thank you
Reply With Quote
  #5 (permalink)  
Old 03-20-04, 01:48 PM
Infinite_Hackers's Avatar
Infinite_Hackers Infinite_Hackers is offline
Coding Addict
 
Join Date: Dec 2003
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:

if( isset($_GET['act']) ) {

switch (
$_GET['act'])
{
case 
"add":
include(
'add.tpl');
break;
default:
include(
'index.tpl');

} else {
include(
'index.tpl');

See, if the 'act' is not given a value you cannot switch it..so you just check if it is...or not
__________________
New beta project: GFX-PRO.ATH.CX
Description: GFX-PRO a great new project that anyone can and setup in less then a minute. [ More info ]
Website: http://gfx-pro.ath.cx
Status: Online
http://gfx-pro.ath.cx/sig.png
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Include Problem DAL Perl 3 11-20-04 07:45 AM
User Authentication and Session problem!!! askme PHP 1 02-06-04 09:10 AM
Small problem for a pro, but for novice like me... argh! ntek Perl 3 11-19-03 01:45 PM
file download problem ukyankee Perl 6 10-04-03 10:39 PM
jpGraph axis labeling problem Squeezer PHP 2 08-20-03 07:53 AM


All times are GMT -5. The time now is 10:20 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.