I am using zend studio for coding in php.
In zend studio
the line of while...
in following code shows assignment in condition
warning but it work fine and show me tables instantly.
$oDB = new db;
print '<strong>Twitter Database Tables</strong><br />';
$result = $oDB->select('SHOW TABLES');
while ($row = mysqli_fetch_row($result)) {
print $row[0] . '<br />';
}
But when I solve this warning with the following code it don't show warning in zend studio
but it show me tables after long time about 20 to 30 seconds
and long white space under results. Why?
$oDB = new db;
print '<strong>Twitter Database Tables</strong><br />';
$result = $oDB->select('SHOW TABLES');
while (( $row = mysqli_fetch_row($result)) !==FALSE) {
print $row[0] . '<br />';
}
According to the manual:
mysqli_fetch_row() returns an array of strings that corresponds to the fetched row or NULL if there are no more rows in result set.
You're checking for a BOOL response, so the script continues on. Use either != FALSE or !== NULL.
The code would either be:
while (($row = mysqli_fetch_row($result)) != FALSE) {
OR
while (($row = mysqli_fetch_row($result)) !== NULL) {