Page 1 of 1

Transferring scripts

Posted: Tue Jan 28, 2003 7:52 am
by Nunners
I have a script which I wrote about 2 years ago, that uses post variables.

One of the things it checks for is, does the variable exist - i.e. is it NOT NULL.....

How can you do that, as when I try using it, it just tells me, with a warning error, that the varilable is undefined...?

Re: Transferring scripts

Posted: Tue Jan 28, 2003 8:07 am
by twigletmac
Nunners wrote:I have a script which I wrote about 2 years ago, that uses post variables.

One of the things it checks for is, does the variable exist - i.e. is it NOT NULL.....

How can you do that, as when I try using it, it just tells me, with a warning error, that the varilable is undefined...?
Do you do:

Code: Select all

if (!$variable) {
   echo 'var not set';
} else {
   echo 'var is set';
}
if so change it to something like

Code: Select all

if (!isset($variable)) {
   echo 'var not set';
} else {
   echo 'var is set';
}
Using isset() or empty() should mean you don't get the variable undefined errors for the if statement.

Mac

Re: Transferring scripts

Posted: Tue Jan 28, 2003 8:09 am
by twigletmac
Do you do:

Code: Select all

if (!$variable) {
   echo 'var not set';
} else {
   echo 'var is set';
}
if so change it to something like

Code: Select all

if (!isset($variable)) {
   echo 'var not set';
} else {
   echo 'var is set';
}
Using isset() or empty() should mean you don't get the variable undefined errors for the if statement.

Mac

Posted: Tue Jan 28, 2003 8:13 am
by Nunners
I have been using (!$var) but I'm now going through and doing !isset and it works... thanks for your help....