可能重複:
mysql_fetch_array()預計參數1是資源問題
我不明白這一點,我看不出有任何的錯誤在此代碼,但是有這個錯誤,請幫助:
mysql_fetch_array()期望參數1成爲資源問題
<?php
$con = mysql_connect("localhost","root","nitoryolai123$%^");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("school", $con);
$result = mysql_query("SELECT * FROM student WHERE IDNO=".$_GET['id']);
?>
<?php while ($row = mysql_fetch_array($result)) { ?>
<table class="a" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#D3D3D3">
<tr>
<form name="formcheck" method="get" action="updateact.php" onsubmit="return formCheck(this);">
<td>
<table border="0" cellpadding="3" cellspacing="1" bgcolor="">
<tr>
<td colspan="16" height="25" style="background:#5C915C; color:white; border:white 1px solid; text-align: left"><strong><font size="2">Update Students</td>
<tr>
<td width="30" height="35"><font size="2">*I D Number:</td>
<td width="30"><input name="idnum" onkeypress="return isNumberKey(event)" type="text" maxlength="5" id='numbers'/ value="<?php echo $_GET['id']; ?>"></td>
</tr>
<tr>
<td width="30" height="35"><font size="2">*Year:</td>
<td width="30"><input name="yr" onkeypress="return isNumberKey(event)" type="text" maxlength="5" id='numbers'/ value="<?php echo $row["YEAR"]; ?>"></td>
<?php } ?>
我只是試圖加載數據的形式,但我不知道爲什麼會出現錯誤。這可能是什麼錯誤?
我建議至少投'$ _GET [ '身份證']''到int': '的mysql_query(」 SELECT * FROM student WHERE IDNO =「。(int)$ _ GET ['id']);' – binaryLV 2010-04-23 09:29:17