Here's my problem:
$q = 'SELECT * FROM s_stats WHERE srv_id='.$sid.' ORDER BY date DESC LIMIT 5';
$result = mysql_query($q) or die(mysql_error());
while ($row = mysql_fetch_array($result))
{
if ($row[percent] == null) //开发者_如何学Python don't work
$procent[] = 1;
else
$procent[] = $row[percent];
}
$procent[] = implode('-', $procent);
Try: if ($row["percent"] == null || $row["percent"] == "")
try
if ($row[percent] === null)
When using the non-strict ==
operator, 0 == null
and '' == null
will evaluate to true as well, which is probably not desirable.
$q = 'SELECT * FROM s_stats WHERE srv_id='.$sid.' ORDER BY date DESC LIMIT 5';
$result = mysql_query($q) or die(mysql_error());
while ($row = mysql_fetch_array($result))
{
echo '*', $row['percent'], '*<br/>';
if (!isset($row["percent"]))
$procent[] = 1;
else
$procent[] = $row[percent];
}
$procent[] = implode('-', $procent);
and print:
12
4
66
Maybe if (! isset($row['percent']))
instead of if ($row['percent'] == null)
精彩评论