PHP出现这个问题,求解!Call to a member function fetch_assoc() on a non-object i
<?php$xh=$_GET['xh'];$db=newmysqli("localhost","root","","test");$q="select*fromstuwh...
<?php
$xh=$_GET['xh'];
$db=new mysqli("localhost","root","","test");
$q= "select * from stu where xh=$xh";
$r=$db->query($q);
$row=$r->fetch_assoc();
?>
<form action="save.php">
<p>学号:<input type=text name=xh value=<?php echo $row['xh'];?> size=20 readonly> </p>
<p>姓名:<input type=text name=xm value=<?php echo $row['xm'];?> size=20> </p>
<p>性别:<input type=radio value=0 <?php if($row['xb']==0) echo "checked";?> name=xb >male<input type=radio value=1 <?php if($row['xb']==1) echo "checked";?> name=xb >female</p>
<p><input type=submit value="提交" name=tj>
<input type=reset value="重置" name=cz></p>
</form>
<?
$r->free();
$db->close();
?> 展开
$xh=$_GET['xh'];
$db=new mysqli("localhost","root","","test");
$q= "select * from stu where xh=$xh";
$r=$db->query($q);
$row=$r->fetch_assoc();
?>
<form action="save.php">
<p>学号:<input type=text name=xh value=<?php echo $row['xh'];?> size=20 readonly> </p>
<p>姓名:<input type=text name=xm value=<?php echo $row['xm'];?> size=20> </p>
<p>性别:<input type=radio value=0 <?php if($row['xb']==0) echo "checked";?> name=xb >male<input type=radio value=1 <?php if($row['xb']==1) echo "checked";?> name=xb >female</p>
<p><input type=submit value="提交" name=tj>
<input type=reset value="重置" name=cz></p>
</form>
<?
$r->free();
$db->close();
?> 展开
展开全部
if(isset($_GET['xh'])){
$xh=$_GET['xh'];
$db=new mysqli("localhost","root","","test");
$q= "select * from stu where xh=".intval($xh);
$r=$db->query($q);
$row=$r->fetch_assoc();
}
追问
谢谢你,这个问题是解决了,但是下面的表单出现问题了,你可以再帮我看看吗,就是value=这里出现问题了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |