0

Problem

While I am fetching information from mysql, I also want to check that some specify column in mysql row is 0.

But then I get the notice Undefined Variabe yet the code works?

Code Line 157:

        while($row = $fetch->fetch( PDO::FETCH_ASSOC  ) && $row['status'] == 0) {

Error I get

Notice: Undefined variable: row in C:\xampp\htdocs\recover\admin\index.php on line 157

My question:

How do I get rid of that error without creating a if statement under the while loop? I basically want it to handle this in the while loop, if I am not doing that wrong?.

Is using a if statement under the while loop better than using it in the while loop?

What is causing the error? I am already defining what $row is before the && row['status'] == 0.

Thanks

4

1 回答 1

4

You need parentheses:

while(($row = $fetch->fetch( PDO::FETCH_ASSOC  )) && $row['status'] == 0)
于 2013-03-30T20:20:28.407 回答