Re: checking
| From: | Justin French | Date: | Fri, 28 Jun 2002 07:31:01 +0000 |
| Subject: | Re: checking | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-104269@lists.php.net to get a copy of this message | ||
try empty()
if(empty($lastname))
{
$badvalue = 1;
}
if(empty($firstname))
{
$badvalue = 1;
}
if(!$badvalue)
{
// insert
}
I'd really advise using 1/0 or TRUE/FALSE instead of yes/no for values like
$insert, because the if statements are a lot quicker to write:
if($value) { ... } or if(!$value) { ... }
rather than
if($value == "yes") { ... } or if($value == "no") { ... }
read this whole page:
http://www.php.net/manual/en/language.types.boolean.php
and
http://www.php.net/manual/en/function.empty.php
Regards,
Justin French
on 28/06/02 4:20 PM, Martin Towell (martin.towell@world.net) wrote:
> see if isset() works for you
>
> -----Original Message-----
> From: Leo [mailto:kaleonardo@BonBon.net]
> Sent: Thursday, June 27, 2002 6:42 PM
> To: php.net
> Subject: [PHP] checking
>
>
> I have a form and I don't want to insert recording with blank value.
> I put:
> if ($lastname="") {
> $insert="no"
> }
> if ($insert="no"){
> do not insert;
> else
> insert;
> }
> my probleme is in some case $lastname="" is true and other case is false.
> I tried with $lastname=" " but no change. how can I check if a varible is
> empty or not?
>
> leo
>
>