一直困扰我的一件事是,当检查我的php脚本中的问题时,我收到警告"bool-assign:Assignment in condition",我得到了很多.例如:
$guests = array(); $sql = "SELECT * FROM `guestlist`"; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)) $guests[] = $row['name'];
有多种方法可以将多个或所有行放入对象或数组中吗?或者这种方法没有错?
尝试这样做:
$guests = array(); $sql = "SELECT * FROM `guestlist`"; $result = mysql_query($sql); while(($row = mysql_fetch_assoc($result)) !== false) $guests[] = $row['name'];
我相信php是警告,因为$ row = mysql_fetch_assoc($ result)没有返回布尔值.