[thelist] php: problem with variable

Peter Van Dijck peter.vandijck at vardus.com
Wed Jan 23 08:47:18 CST 2002


> If (!$submit)
> {...print form
>
> but I was getting undefined variable errors.  So I changed it to:
>
> If (!defined('$submit'))
> {...print form
>
> (and you wouldn't believe how long it took me to figure even that out!).
> Now it just seems to ignore the fact that I've pressed the button, ie.,
the
> result of "!defined('$submit'))" is 1 (true), even though "print $submit;"
> returns the correct answer.  Going back to RTFM I noticed that "defined()"
> works for constants, implying it wouldn't work in this case, right?

No, a constant is a variable that is defined like this:
define (THISISACONSTANT, "value");
Don't use the defined() function, it has nothing to do here.

Go back to finding out what's going on with the $submit. This code:
if(!$submit) {
should work fine in ALL versions of PHP, even the most recent.

So step 1: at the top of the page
print "submitstring = " . $submit;

Now submit the form. If $submit is not passed on you probably have a problem
in your form (maybe the button is the wrong name). If it is, then the errors
you are getting are coming from somewhere else. So start looking for
variables in the code that look like VARIABLE (without the $), which are
constants, they may not be defined. Good luck.
Peter






More information about the thelist mailing list