Page 1 of 1

Undeclared Variable warnings

Posted: Mon Aug 04, 2003 4:01 pm
by credence
OK here is the deal. I have an input form with check boxes. And the value that is submitted to the database has to be Yes or No. So in my php submission code I have an error checking code that says

If($blah=="") {
$blah="no"
}

however whenver I submit with blah not checked it gives me an undeclared variable warning I would like to get rid of it. Not sure if it would help but I can't change the Post to a Get because the person I am doing this for would rather not have the information in the url.

Thanks in advance,

Jeff

Posted: Mon Aug 04, 2003 4:17 pm
by Drachlen

Code: Select all

<?php

If($blah == ""){ 
$blah="no";
echo $blah;
}

?>
make sure you close things --> $blah="no";

Posted: Tue Aug 05, 2003 12:01 am
by qartis
It would have given a parse error if he had forgotten that semicolon - it's more likely that he just retyped a snippet of his code on-the-fly, thus disregarding perfection.

Try this instead:

Code: Select all

If(!isset($blah)){
$blah="no";
}

Posted: Tue Aug 05, 2003 12:05 pm
by credence
to the 2nd guy to reply thanks a bunch. you hit my problem right on the money. Sorry for my mistyping my code. never new isset existed until now