/    Sign up×
Community /Pin to ProfileBookmark

problem ive never had before: Notice: Undefined index: action in C:Program FilesApa

ive been running my scripts on a free host for a while but recently switched to running on a localhost yesterday. Im running the latest version of php 4.

Basically my script works like this

[code=php]
if($action==””)
{
//whatever
}
elseif($action==”something
{
//whatever
}
elseif($action==”wewe”
{
//whatever
}
[/code]

when i try defining the $action variable as $action=$_GET[‘action’]; i get error in the topic subject and when i dont define it all iget

Notice: Undefined variable: action in C:Program FilesApache GroupApache2htdocsgameindex.php on line 14

Notice: Undefined variable: action in C:Program FilesApache GroupApache2htdocsgameindex.php on line 20

Notice: Undefined variable: action in C:Program FilesApache GroupApache2htdocsgameindex.php on line 56

Notice: Undefined variable: action in C:Program FilesApache GroupApache2htdocsgameindex.php on line 86

Notice: Undefined variable: action in C:Program FilesApache GroupApache2htdocsgameindex.php on line 98

when i was running it online i did not define the action variable and used the programming style above and it worked. Is there anything i can do?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@JonaApr 10.2004 — [font=arial]It's because the way your online server supports sloppy coding. You should use this[/font]

[code=php]
if(isset($_GET["action"]))
{ $action = $_GET["action"]; }
else
{ $action = ""; }
[/code]


[font=arial]...instead of this[/font]

[code=php]
$action = $_GET["action"];
[/code]
×

Success!

Help @Conor spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...