Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5272464
  • 博文数量: 1144
  • 博客积分: 11974
  • 博客等级: 上将
  • 技术积分: 12312
  • 用 户 组: 普通用户
  • 注册时间: 2005-04-13 20:06
文章存档

2017年(2)

2016年(14)

2015年(10)

2014年(28)

2013年(23)

2012年(29)

2011年(53)

2010年(86)

2009年(83)

2008年(43)

2007年(153)

2006年(575)

2005年(45)

分类: LINUX

2006-12-08 10:23:10

菜鸟问题 请高手指教!!!Warning: mysql_num_rows(): supplied argument is not a valid MySQL result....
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\inetpub\wwwroot\web\index.php on line 27
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in c:\inetpub\wwwroot\web\index.php on line 28
请问是什么出错
 
 
 
 
wjjchen(redfox) 于 2005-10-8 16:15:40
sql语句执行结果没有取得数据,在确认sql语句没有错的情况下可以在函数前加上@符号不显示错误信息。
 
 
 
coolstr(占卜師oοΟ) 于 2005-10-8 16:31:52
sql语句错误 。。
 
 
 
cmgg 于 2005-10-8 16:37:51
sql语句如下:
$sql="select * from new where NewType='图片新闻' ";
应该怎么改啊
 
 
 
ice_berg16(寻梦的稻草人) 于 2005-10-8 16:41:58
$sql没有错误,应该是代码的问题
 
 
 
cmgg 于 2005-10-8 17:01:38
//index.php
$mylink=DBConnect();
$sql="select * from new where NewType='图片新闻' ";
$result=mysql_query($sql,$mylink);
$rows=mysql_num_rows($result);
$newinfo= mysql_fetch_object($result);
?>
//connect.php
function DBConnect(){
$conn=mysql_connect('localhost','root','');
if($conn)mysql_select_db('aa');
return $conn;
?>
aa.sql中有 new表 和 图片新闻的记录
 
 
 
goldily(goldily) 于 2005-10-8 17:18:16
select * from new where NewType='图片新闻'
可以直接用数据库试试该查询有没有记录
 
 
 
zhongjihang 于 2005-10-8 17:21:44
没记录也不会错啊,主要是sql写错了,你看看你的字段名是不是写错了
 
 
 
Mistruster(弱智d) 于 2005-10-8 18:03:15
mysql_query() 没报错说明数据库连接正常
mysql_num_rows($result); 报错说明 $reuslt 变量不正确
如果查询语句正确,mysql_num_rows($result);返回的是记录数,没有记录则为0不会报错
在mysql_query()语句后写print_r($result);如果有Resource id #n则正确,否则SQL语句写错了
 
阅读(1506) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~