|
Posted by Rik Wasmus on 11/09/07 19:07
On Fri, 09 Nov 2007 19:57:49 +0100, Big Moxy <bigmoxy@gmail.com> wrote:
> On Nov 9, 10:11 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>> Big Moxy wrote:
>> > On Nov 9, 9:38 am, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:=
>> >> On Fri, 09 Nov 2007 18:25:36 +0100, Big Moxy <bigm...@gmail.com> =
>> wrote:
>> >>> $rows =3D mysql_num_rows($result) or die(mysql_error());
>> >> How do you think this well act if the result of mysql_num_rows() i=
s =
>> 0?
>> > I want mysql_num_rows() =3D 0 to be treated as a not found conditio=
n.
>> > Isn't that already handled?
>>
>>
>> Rik is correct.
>>
>> Figure out what this statement does:
>>
>> $rows =3D mysql_num_rows($result) or die(mysql_error());
>>
>> Then figure out why it isn't good to use die() *anywhere* in producti=
on
>> code.
>
> How do I differtiate 0 from some other error?
A variable is never an error.
> I want true errors to be
> handled differently than the basic not found condition.
if($var) echo '$var cast to boolean is true';
else echo '$var cast to boolean is false';
if($var=3D=3D=3Dtrue){
echo '$var is a boolean and is true';
} else if($var=3D=3D=3Dfalse){
echo '$var is a boolean and is false';
} else {
echo '$var is not actually a boolean';
}
In this particular case you don't need strict comparison though. Just =
remove the or die() after mysql_num_rows() and your code will work as =
intended as far is I can see glancing over it quickly.
-- =
Rik Wasmus
[Back to original message]
|