我有一些非常簡單的代碼:MySQL的:未定義的指標,即使它們已經被定義
$result = mysql_query("
SELECT max(id) as id, ip, max(entry), COUNT(ip) AS count
FROM table_name
GROUP BY ip
ORDER BY max(id) asc
");
$i = 0;
$num_rows = mysql_num_rows($result);
echo $num_rows;
while($row = mysql_fetch_row($result)) {
$id = $row['id'];
$entry = $row['entry'];
$ip = $row['ip'];
$count = $row['count'];
$i++;
?>
<tr width="100%" align="center">
<td><?php echo $i; ?></td>
<td><?php echo $id; ?></td>
<td><?php echo $entry; ?></td>
<td><?php echo $ip; ?></td>
<td><?php echo $count; ?></td>
<td>
<form style="display:inline;" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" value="<?php echo $ip; ?>" name="ip" />
<input type="hidden" value="<?php echo $id; ?>" name="id" />
<input type="submit" value="Ban IP" name="submit" />
</form>
</td>
</tr>
<?php
}
的問題是,當我運行它,我得到:
Notice: Undefined index: id
Notice: Undefined index: entry
Notice: Undefined index: ip
Notice: Undefined index: count
但據正如我所看到的,我已經在SQL語句中定義了索引,任何幫助將不勝感激。它使用的列名ID,IP,進入選擇數據和IP公司的計數創建索引「計數」,那麼爲什麼它說,它沒有被定義?
對不起,如果描述似乎稀疏,我只是不知道如何描述它 – AviateX14