提取数据库数据 并循环显示 php
我想将评论内容显示出来,这是数据库:这是显示的代码:<?php$conn=mysql_connect("localhost","root","")ordie("数据库连接...
我想将评论内容显示出来, 这是数据库:
这是显示的代码:
<?php
$conn = mysql_connect("localhost", "root", "") or die("数据库连接失败".mysql.error());
mysql_select_db("ausspeace") or die ("没有数据库".mysql.error());
$id = "myself1";
$sql = "select * from speace_comment where connect = $id and state = '已审核' order by comment_id desc";
$result_set = mysql_query($sql);
echo "评论信息如下<br/>";
while ($row = mysql_fetch_array($result_set)) {
echo "评论者:".$row['username']."<br/>";
echo "评论内容:".$row['content']."<br/>";
echo "日期:".$row['publish_time']."<br/>";
echo "IP地址:".$row['ip']."<br/>";
echo "<hr/>";
}
?>
while那行提示报错
Warning: mysql_fetch_array() expects parameter 1 to be resource,
怎么办? 谢谢! 展开
这是显示的代码:
<?php
$conn = mysql_connect("localhost", "root", "") or die("数据库连接失败".mysql.error());
mysql_select_db("ausspeace") or die ("没有数据库".mysql.error());
$id = "myself1";
$sql = "select * from speace_comment where connect = $id and state = '已审核' order by comment_id desc";
$result_set = mysql_query($sql);
echo "评论信息如下<br/>";
while ($row = mysql_fetch_array($result_set)) {
echo "评论者:".$row['username']."<br/>";
echo "评论内容:".$row['content']."<br/>";
echo "日期:".$row['publish_time']."<br/>";
echo "IP地址:".$row['ip']."<br/>";
echo "<hr/>";
}
?>
while那行提示报错
Warning: mysql_fetch_array() expects parameter 1 to be resource,
怎么办? 谢谢! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询