RE: [PHP-DB] Why does this conditional run, even if not true?
Bastien, Thanks for your reply (and on the weekend, no less!). I went back and looked and the function does return only "YES" or "NO" so that wasn't the problem. What I found to be the problem was that my while loop inside the IF clause was running no matter what. So what I did was put the while loop in it's own function and voila! no more problems. PHP is funny. It seems to trip on it's own shoestrings sometimes. (either that or I didn't RTFM) :) Cheers, Karen Bastien Koert <[EMAIL PROTECTED]> wrote: hard to say without the code for the function...what is returned by the fuction determines if the code runs, right? Are you sure the code is returning "YES"? Maybe post the code for the function bastien >From: Karen Resplendo >To: [EMAIL PROTECTED] >Subject: [PHP-DB] Why does this conditional run, even if not true? >Date: Fri, 8 Oct 2004 18:33:02 -0700 (PDT) > >$c is a field in an array I have loaded in from a text file. For some >reason, none of the conditionals branch off and I end up printing out error >messages for every row in the text file. My brackets are balanced, I just >didn't include the bottom part: > >If ($c==9) > { > If($fieldarray[3]=="P") > { > > $reject=validate($fieldarray[0],$c,$connectionSDWIS, >$fieldarray[$c],$c); > >This If statement runs even if $reject = "YES". Can't figure out why: > > > if ($reject=="NO") > { > >// > //loop through the rows in the this text file checking for Original >ID of Repeat > >// > $handle2 = fopen ($uploadfileandpath,"r"); > while ($field2array = fgetcsv ($handle2, $userfile_size, ",")) > { > If($field2array[2]!=$fieldarray[$c]) > { > echo " Field 2 of array 2 text row: >".$field2array[2]." "; > echo " Field 9 of array 1 text row: >".$fieldarray[$c]." "; > $acceptOrReject = "R"; > $displayrows.="See below: Original Sample >ID for Repeat does not exist : ".$fieldarray[$c]." "; > > } > > } //end of while loop > > fclose($handle2); > > }//end of If($reject =="No") > > >- >Do you Yahoo!? >Yahoo! Mail Address AutoComplete - You start. We finish. _ Don't just Search. Find! http://search.sympatico.msn.ca/default.aspx The new MSN Search! Check it out! - Do you Yahoo!? vote.yahoo.com - Register online to vote today!
RE: [PHP-DB] Why does this conditional run, even if not true?
hard to say without the code for the function...what is returned by the fuction determines if the code runs, right? Are you sure the code is returning "YES"? Maybe post the code for the function bastien From: Karen Resplendo <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: [PHP-DB] Why does this conditional run, even if not true? Date: Fri, 8 Oct 2004 18:33:02 -0700 (PDT) $c is a field in an array I have loaded in from a text file. For some reason, none of the conditionals branch off and I end up printing out error messages for every row in the text file. My brackets are balanced, I just didn't include the bottom part: If ($c==9) { If($fieldarray[3]=="P") { $reject=validate($fieldarray[0],$c,$connectionSDWIS, $fieldarray[$c],$c); This If statement runs even if $reject = "YES". Can't figure out why: if ($reject=="NO") { // //loop through the rows in the this text file checking for Original ID of Repeat // $handle2 = fopen ($uploadfileandpath,"r"); while ($field2array = fgetcsv ($handle2, $userfile_size, ",")) { If($field2array[2]!=$fieldarray[$c]) { echo "Field 2 of array 2 text row: ".$field2array[2].""; echo "Field 9 of array 1 text row: ".$fieldarray[$c].""; $acceptOrReject = "R"; $displayrows.="See below: Original Sample ID for Repeat does not exist : ".$fieldarray[$c].""; } } //end of while loop fclose($handle2); }//end of If($reject =="No") - Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish. _ Don't just Search. Find! http://search.sympatico.msn.ca/default.aspx The new MSN Search! Check it out! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Why does this conditional run, even if not true?
$c is a field in an array I have loaded in from a text file. For some reason, none of the conditionals branch off and I end up printing out error messages for every row in the text file. My brackets are balanced, I just didn't include the bottom part: If ($c==9) { If($fieldarray[3]=="P") { $reject=validate($fieldarray[0],$c,$connectionSDWIS, $fieldarray[$c],$c); This If statement runs even if $reject = "YES". Can't figure out why: if ($reject=="NO") { // //loop through the rows in the this text file checking for Original ID of Repeat // $handle2 = fopen ($uploadfileandpath,"r"); while ($field2array = fgetcsv ($handle2, $userfile_size, ",")) { If($field2array[2]!=$fieldarray[$c]) { echo "Field 2 of array 2 text row: ".$field2array[2].""; echo "Field 9 of array 1 text row: ".$fieldarray[$c].""; $acceptOrReject = "R"; $displayrows.="See below: Original Sample ID for Repeat does not exist : ".$fieldarray[$c].""; } } //end of while loop fclose($handle2); }//end of If($reject =="No") - Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish.