On 18-Jun-2003 Becoming Digital wrote:

 ...

>> if(!mysql_query($array[$i])) {
>>   $flag = false;
>>    break;
>> }
>>
>> after the loop I do
>> if($flag)
>>   mysql_query("commit");
>> else
>>   mysql_query("rollback");
> 
> Be careful with that last if() statement.  I would either change the
> script to
> read '$flag = true' or 'if( isset($flag) )'
> 
> It's quite possible that I'm mistaken, but I believe that 'if($flag)'
> would
> evaluate to false if '$flag = false'.
> 

The constant FALSE (or false) will never evaluate as a TRUE condition.


if ($flag = true)   // this assigns TRUE to $flag and then the 
                    // value of $flag will be evaluated.

if (isset($flag))  // will evaluate as TRUE because $flag has a value
                   // assigned. It's not NULL. 
                   //  -- regardless of what the value is.

if ($flag) {
 -- or (assuming $flag is initialized) --
if ($flag === TRUE) {

  ... so either would be the correct construct here.

Regards,
-- 
Don Read                                       [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
                            (53kr33t w0rdz: sql table query)


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to