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...?
Checking post variables are set
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Re: Transferring scripts
Do you do: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...?
Code: Select all
if (!$variable) {
echo 'var not set';
} else {
echo 'var is set';
}Code: Select all
if (!isset($variable)) {
echo 'var not set';
} else {
echo 'var is set';
}Mac
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Re: Transferring scripts
Do you do:
if so change it to something like
Using isset() or empty() should mean you don't get the variable undefined errors for the if statement.
Mac
Code: Select all
if (!$variable) {
echo 'var not set';
} else {
echo 'var is set';
}Code: Select all
if (!isset($variable)) {
echo 'var not set';
} else {
echo 'var is set';
}Mac