<body>
<?php
$conn=mysql_connect("localhost","root","9909900") or die("数据库服务器连接错误".mysql_error());
mysql_select_db("test",$conn) or die("数据库访问错误".mysql_error());
mysql_query("set names gb2312");
$id=$_GET[id];
$sql="select * from xuesheng where id=$id";
$result= mysql_query($sql);
$info=mysql_fetch_array($result);
?>
<form action="editok.php" name="thisform" method="post">
id: <INPUT name="id "maxLength=25 size=16 value=<?php echo $info[id];?>><br>
姓名:<INPUT name="name "maxLength=25 size=16 value=<?php echo $info[name];?>><br>
性别:<input type="radio" name="sex" value="男"<?php if($info[sex]=='男') echo " checked=\"checked\""; ?> >男
<input type="radio" name="sex" value="女"<?php if($info[sex]=='女') echo " checked=\"checked\""; ?> >女<br>
出生年月:<INPUT maxLength=4 size=4 name=year value=<?php echo $info[year];?>>年 <INPUT maxLength=2 size=2 name=month value=<?php echo $info[month];?>>月
<INPUT maxLength=2 size=2 name=day value=<?php echo $info[day];?>>日<br>
备注:<textarea cols="50" rows="4" name="note"><?php echo $info[note];?></textarea>
<br>
<input type="submit" name="submit_button" value="修改" onclick="return check(thisform)">
<input type="reset" name="reset_button" value="重置"></form>
</body>
浏览器报Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in E:\web\xuesheng\edit.php on line 47各位高手帮忙看下是什么问题
<?php
$conn=mysql_connect("localhost","root","9909900") or die("数据库服务器连接错误".mysql_error());
mysql_select_db("test",$conn) or die("数据库访问错误".mysql_error());
mysql_query("set names gb2312");
$id=$_GET[id];
$sql="select * from xuesheng where id=$id";
$result= mysql_query($sql);
$info=mysql_fetch_array($result);
?>
<form action="editok.php" name="thisform" method="post">
id: <INPUT name="id "maxLength=25 size=16 value=<?php echo $info[id];?>><br>
姓名:<INPUT name="name "maxLength=25 size=16 value=<?php echo $info[name];?>><br>
性别:<input type="radio" name="sex" value="男"<?php if($info[sex]=='男') echo " checked=\"checked\""; ?> >男
<input type="radio" name="sex" value="女"<?php if($info[sex]=='女') echo " checked=\"checked\""; ?> >女<br>
出生年月:<INPUT maxLength=4 size=4 name=year value=<?php echo $info[year];?>>年 <INPUT maxLength=2 size=2 name=month value=<?php echo $info[month];?>>月
<INPUT maxLength=2 size=2 name=day value=<?php echo $info[day];?>>日<br>
备注:<textarea cols="50" rows="4" name="note"><?php echo $info[note];?></textarea>
<br>
<input type="submit" name="submit_button" value="修改" onclick="return check(thisform)">
<input type="reset" name="reset_button" value="重置"></form>
</body>
浏览器报Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in E:\web\xuesheng\edit.php on line 47各位高手帮忙看下是什么问题
$sql="select * from xuesheng where id=$id";
这句打出来!应该是你的sql语句在数据库里执行错误!
$conn=mysql_connect("localhost","root","9909900") or die("数据库服务器连接错误".mysql_error());
mysql_select_db("test",$conn) or die("数据库访问错误".mysql_error());
mysql_query("set names gb2312");
if(isset($_GET[id])){//判断是否存在在执行查询
$id=$_GET[id];
$sql="select * from xuesheng where id=$id";
$result= mysql_query($sql);
$info=mysql_fetch_array($result);
}
我的$id 是前面有个页面带过来的,前面页面的代码 <?php
$link=mysql_connect("localhost","root","9909900") or die("数据库连接失败".mysql_error());
mysql_select_db("test",$link);
mysql_query("set names gb2312");
$sql=mysql_query("select * from xuesheng");
$info=mysql_fetch_array($sql);
if ($_POST[Submit]=="查询"){
$name=$_POST[name];
$sql=mysql_query("select * from xuesheng where name like '%".trim($name)."%'"); //如果选择的条件为"like",则进行模糊查询
$info=mysql_fetch_array($sql);
}
if($info==false){ //如果检索的信息不存在,则输出相应的提示信息
echo "<div align='center' style='color:#FF0000; font-size:12px'>对不起,您检索的学生信息不存在!</div>";
}
do{
?>
<tr align="left" bgcolor="#FFFFFF">
<td height="20" align="center"><?php echo $info[id]; ?></td>
<td > <?php echo $info[name]; ?></td>
<td align="center"><?php echo $info[sex]; ?></td>
<td align="center"><?php echo $info[year]."年".$info[month]."月".$info[day]."日"; ?></td>
<td align="center"> <?php echo $info[note]; ?></td>
<td align="center"><a href="edit.php?id=<?php echo $info[id];?>"><img src="images/update.gif" width="20" height="18" border="0"></a></td>
</tr>
<?php
}
while($info=mysql_fetch_array($sql));
?>
{
//这里拼接一下数组
}即可