Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, object given in F:\AppServ\w
<?phpfunctiondb_connect(){$db=@newmysqli("localhost","root","900111","test");if(mysql...
<?php
function db_connect()
{
$db=@new mysqli("localhost","root","900111","test");
if(mysqli_connect_error())
{
echo '数据库连接失败!<br>';
echo mysqli_connect_error();
exit;
}
return $db;
$db->close();
}
$db=db_connect();
$sql="select*from test";
$conn=$db->query($sql);
$num=$conn->num_rows;
echo $num;
$pagesize=5;
$pagetal=1;
if($_GET[page])
{
$pagetal=$_GET[page];
$page=($pagetal-1)*$pagesize;
}
$sql="select*from test limit $page,$pagesize";
$conn=$db->query($sql);
while($row=mysqli_fetch_array($db,$conn))
{
echo $row['name'].$row['sex'];
}
echo "共".$num."条"."<a href=12.php?page=".($pagetal-1).">上一页</a><a href=12.php?page=".($pagetal+1).">下一页</a>";
?>
谁能帮我看看是哪里出错了。。感激不尽。。 展开
function db_connect()
{
$db=@new mysqli("localhost","root","900111","test");
if(mysqli_connect_error())
{
echo '数据库连接失败!<br>';
echo mysqli_connect_error();
exit;
}
return $db;
$db->close();
}
$db=db_connect();
$sql="select*from test";
$conn=$db->query($sql);
$num=$conn->num_rows;
echo $num;
$pagesize=5;
$pagetal=1;
if($_GET[page])
{
$pagetal=$_GET[page];
$page=($pagetal-1)*$pagesize;
}
$sql="select*from test limit $page,$pagesize";
$conn=$db->query($sql);
while($row=mysqli_fetch_array($db,$conn))
{
echo $row['name'].$row['sex'];
}
echo "共".$num."条"."<a href=12.php?page=".($pagetal-1).">上一页</a><a href=12.php?page=".($pagetal+1).">下一页</a>";
?>
谁能帮我看看是哪里出错了。。感激不尽。。 展开
2个回答
展开全部
rom ad_constitution as A inner join ad_constitution1 as B on A.school_code=B.school_code_id ORDER BY id DESC LIMIT 18
中的ORDER BY id 是谁的id ,是A的还是B的 ,应该是 A.id 或 B.id 。
例如sql语句是: "select * from ad_constitution as A inner join ad_constitution1 as B on A.school_code=B.school_code_id ORDER BY A.id DESC LIMIT 18 " 。
中的ORDER BY id 是谁的id ,是A的还是B的 ,应该是 A.id 或 B.id 。
例如sql语句是: "select * from ad_constitution as A inner join ad_constitution1 as B on A.school_code=B.school_code_id ORDER BY A.id DESC LIMIT 18 " 。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
mysqli_fetch_array($db,$conn)两个参数颠倒一下 改成mysqli_fetch_array($conn)看看
追问
还是不对。。还是谢谢你拉。。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询