|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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? |
|
#2
|
|||
|
|||
|
RE: error for an iff statement
Where does $action obtain its value from?
|
|
#3
|
|||
|
|||
|
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") |
|
#4
|
|||
|
|||
|
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... |
|
#5
|
|||
|
|||
|
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? |
|
#6
|
|||
|
|||
|
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) { |
|
#7
|
|||
|
|||
|
RE: error for an iff statement
it is register_globals problem. turn them to on, or use $_GET['action'] and $_POST['username'] instead...
|
|
#8
|
|||
|
|||
|
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 ... |
|
#9
|
|||
|
|||
|
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) |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > error for an iff statement |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|