PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old October 30th, 2002, 05:49 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
error for an iff statement

Warning: Undefined variable: action in c:apachehtdocscomshopshop.php on line 23

i get that error when using this code:

if ($action == "search") {
echo "blah, blah, blah";
}

this same if statement works fine in an administration profram im using,but its not search, it can be something else...
why would i even get an error with this?


Reply With Quote
  #2  
Old October 30th, 2002, 05:55 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: error for an iff statement

Where does $action obtain its value from?

Reply With Quote
  #3  
Old October 30th, 2002, 05:56 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: error for an iff statement

if $action is not defined to begin with, as in $action = null then you will get that error. you can supress it like this:

if(@$action == "search")

Reply With Quote
  #4  
Old October 31st, 2002, 01:32 AM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: error for an iff statement

note that this is not an error, but a warning! there is a diference. with a warning, your script MAY work ok, but php want's to point you to the possibility that it doesn't work ok.

u can hide all the warnings with error_reporting() function if you are shure that your code is perfectly ok, but i would sugest writing code that doesn't generate any warnings and even notices...

ps, try checking with isset($action) to see if it is even set to anything...

Reply With Quote
  #5  
Old October 31st, 2002, 12:57 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: error for an iff statement

the $action comes from a link, like

index.php?action=$variable

that way the action is made by the if statement, so i can use the code all in one page...

wouldnt that be correct?




Reply With Quote
  #6  
Old October 31st, 2002, 01:05 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: error for an iff statement

isset($action)?

well... i dont think it will come up with anything, because technicly there isnt another variable for action,
like: $action = '???';

its just like a login i have, the login goes like this:

if($loginname == $login && $password == $pass) {

include('main.php');

exit;
}
?>
it gives me this warning..
Warning: Undefined variable: loginname in c:apachehtdocscomccshopadminindex.php on line 5

but if i put:
$login = "admin";
$pass = "pass";

it works, or if i place admin, and pass in place of the $login and $pass with no warnings... its like once i add a variable, it dont want to work. and sorry, these variables come from my config.php which has the $login, and $pass variables like above..
$login = "admin";
$pass = "pass";

and i got this script from a tutorial, but cam with:
if($loginname == admin && $password == admin) {

Reply With Quote
  #7  
Old October 31st, 2002, 09:45 PM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: error for an iff statement

it is register_globals problem. turn them to on, or use $_GET['action'] and $_POST['username'] instead...

Reply With Quote
  #8  
Old October 31st, 2002, 11:43 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: error for an iff statement

my register globals are on, how would i use this $_GET['action'] and $_POST['username']? any tutorials anywhere? ive never heard of these yet,,, ill be searching the net in the meantime, and im sure ill find something, theres always something on yahoo when i search for tutorials on php stuff...lol.. thank god...if it wouldnt be for yahoo.com and codewalkers.com... id never be able to get anything done..lol.. Thanks to all of you..
Thanks zombie ...

Reply With Quote
  #9  
Old November 2nd, 2002, 03:56 AM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: error for an iff statement

look at this.

for everything else u need to know about php, i would suggest to look in this order:

1. php manual (and downloadable, my favorite format is chm)

2. www.php.net (and search)

3. www.codewalkers.com (and forums)

4. www.google.com (instead yahooo)

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > error for an iff statement


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT