From: David Mehler on
Hello,
I've been looking at this to long, and am not seeing the issue. When i
had the below php code set to !empty instead of !isset as it is now I
got the value of the name variable echoed back, yet on sql insert that
field, along with all others are empty, though no error is generated,
just a bogus record is inserted.
When I changed to !isset I'm now getting the die statement echoed as
if no value was passed from the form. This is not the case, I filled
it out completely.
Can anyone tell me where this code went wrong?
Thanks.
Dave.

Html form:
<h3>Fields marked with a * (star) are required.</h3>
<form method="post" action="">
<div>
<label for="txtname">Name*:</label>
<input type="text" name="name" /> <br />
</div>

<div>
<input id="reset" name="reset" type="reset"/>
</div>
<div>
<input id="submit" name="submit" type="submit"/>
</div>
</form>
</div>

php Code:
// Check if fields are isset
echo "Field Checs.<br />";
if (!isset($_POST['name'])) {
echo "The value of Name is " . $_POST['name']. "<br />";
} else {
die('ERROR: Missing value - Event Name');
}
From: "Daniel P. Brown" on
On Wed, Jun 30, 2010 at 09:07, David Mehler <dave.mehler(a)gmail.com> wrote:
> Hello,
> I've been looking at this to long, and am not seeing the issue. When i
> had the below php code set to !empty instead of !isset as it is now I
> got the value of the name variable echoed back, yet on sql insert that
> field, along with all others are empty, though no error is generated,
> just a bogus record is inserted.
> When I changed to !isset I'm now getting the die statement echoed as
> if no value was passed from the form. This is not the case, I filled
> it out completely.
> Can anyone tell me where this code went wrong?

Sure.

> php Code:
> // Check if fields are isset
> echo "Field Checs.<br />";
> if (!isset($_POST['name'])) {

.... the line above.

(Hint: isset != empty)



(Another hint: with !empty(), you told PHP, "if it's not empty."
Now, with !isset(), you're saying, "if it's not set.")




(Answer: Remove the exclamation point from !isset().)


--
</Daniel P. Brown>
UNADVERTISED DEDICATED SERVER SPECIALS
SAME-DAY SETUP
Just ask me what we're offering today!
daniel.brown(a)parasane.net || danbrown(a)php.net
http://www.parasane.net/ || http://www.pilotpig.net/
From: Richard Quadling on
On 30 June 2010 14:23, Daniel P. Brown <daniel.brown(a)parasane.net> wrote:
>    (Hint: isset != empty)

More importantly ...

isset != !empty

$a = Null;
$b = '';
// $c = undefined;
$d = 'Hello';

isset($a) = False vs True = empty($a)
isset($b) = True vs True = empty($b)
isset($c) = False vs True = empty($c)
isset($d) = True vs False = empty($d)



--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling
From: Shreyas Agasthya on
http://www.php.net/manual/en/types.comparisons.php

<http://www.php.net/manual/en/types.comparisons.php>The first table actually
gives a very good understanding.

--Shreyas

On Wed, Jun 30, 2010 at 7:05 PM, Richard Quadling <rquadling(a)gmail.com>wrote:

> On 30 June 2010 14:23, Daniel P. Brown <daniel.brown(a)parasane.net> wrote:
> > (Hint: isset != empty)
>
> More importantly ...
>
> isset != !empty
>
> $a = Null;
> $b = '';
> // $c = undefined;
> $d = 'Hello';
>
> isset($a) = False vs True = empty($a)
> isset($b) = True vs True = empty($b)
> isset($c) = False vs True = empty($c)
> isset($d) = True vs False = empty($d)
>
>
>
> --
> -----
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Regards,
Shreyas Agasthya
From: Richard Quadling on
On 30 June 2010 14:53, Shreyas Agasthya <shreyasbr(a)gmail.com> wrote:
> http://www.php.net/manual/en/types.comparisons.php
> The first table actually gives a very good understanding.
> --Shreyas
>
> On Wed, Jun 30, 2010 at 7:05 PM, Richard Quadling <rquadling(a)gmail.com>
> wrote:
>>
>> On 30 June 2010 14:23, Daniel P. Brown <daniel.brown(a)parasane.net> wrote:
>> >    (Hint: isset != empty)
>>
>> More importantly ...
>>
>> isset != !empty
>>
>> $a = Null;
>> $b = '';
>> // $c = undefined;
>> $d = 'Hello';
>>
>> isset($a) = False vs True  = empty($a)
>> isset($b) = True  vs True  = empty($b)
>> isset($c) = False vs True  = empty($c)
>> isset($d) = True  vs False = empty($d)
>>
>>
>>
>> --
>> -----
>> Richard Quadling
>> "Standing on the shoulders of some very clever giants!"
>> EE : http://www.experts-exchange.com/M_248814.html
>> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
>> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
>> ZOPA : http://uk.zopa.com/member/RQuadling
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>
>
> --
> Regards,
> Shreyas Agasthya
>

empty() === !boolean()

and

isset() === !is_null()



--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling