警告:mysql_fetch_array():提供的参数不是第40行中的有效MySQL结果 [英] Warning: mysql_fetch_array(): supplied argument is not a valid MySQL Result in line 40

查看:96
本文介绍了警告:mysql_fetch_array():提供的参数不是第40行中的有效MySQL结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能存在重复:

mysql_fetch_array()期望参数1是资源,布尔在给出的选择






我不断收到错误
警告:mysql_fetch_array():提供的参数不是40行中的有效MySQL结果
在我的网页上我不知道为什么..请帮助我。
背景:这个脚本是将我的数据库表拉上名为yname,用户名,密码,日期,评论,作品,dworks
的作品和dworks适合那些尝试过的人,然后他们可以判断如果它
的作品 - 是的,它的工程
dworks - 没有它dosent工作
它应该是投票sortof以及忘记我的问题是像这个脚本的40请帮助我

 < php requirebr.htm?> 
< style>
<?php requirestyles.css?>
< / style>
<?php

$ host =host; //主机名
$ username =name; // Mysql username
$ password =pass; // Mysql密码
$ db_name =dbname; //数据库名称
$ tbl_name =passes; //表名

//连接服务器并选择数据库。
mysql_connect($ host,$ username,$ password)或die(无法连接);
mysql_select_db($ db_name)或死(无法选择DB);

//从mysql中选择记录
$ sql =SELECT * FROM $ tbl_name order by id desc;
$ result = mysql_query($ sql);
?>
< table background ='https://lh6.ggpht.com/DFABQFuYSXLBiB6qlvDPfOONOUxCiwM6_S-dHnjW82iognQToTkORsy7RVXsAz0Y23w=w705'width = '50%'>
< tr>
< th align ='center'> Submition By< / th>< th align ='center'> ScreenName< / th>< th align ='center'> Password< / th> < th align ='center'>这是否正常工作?< / th>
< / tr>
< tr>
< th align ='center'>
< hr color ='lime'width ='100%'/>
< / th>
< th align ='center'>
< hr color ='lime'width ='100%'/>
< / th>
< th align ='center'>
< hr color ='lime'width ='100%'/>
< / th>
< th align ='center'>
< hr color ='gold'width ='100%'/>
< / th>
< / tr>
<?php
while($ rows = mysql_fetch_array($ result)){
?>

< tr>
< td background ='transparent'align ='left'>< i>< b>< ;? echo $ rows ['yname']; ?> < / B>< / I>< / TD>
< td background ='transparent'align ='center'>< i>< b>< ;? echo $ rows ['username']; ?>< / B>< / I>< / TD>
< td background ='transparent'align ='right'>< i>< b>< ;? echo $ rows ['password']; ?>< / B>< / I>< / TD>
< td background ='transparent'align ='right'>< i>< b& nbsp;& nbsp;& nbsp;是<? echo $ rows ['works']; ?>< / B>< / I>< / TD>
< / tr>

<?php
//关闭while循环
}
?>

< / table>

<?php
//关闭连接;
mysql_close();
?>
< center>

我不想重新设定页面的样式,但如果我必须将...如果您看到什么是错误的,请在下面写一个帖子,告诉我它的上线和如何纠正它,然后生病回来,让你知道它是否工作:)谢谢你

解决方案

此错误表示您的查询失败。 mysql_query()返回 false 如果发生错误,则传递 false mysql_fetch_array(),这会触发错误消息。 您的查询可能会失败,原因是丢失/错误的表或字段。要查看详细错误,请打印出 mysql_error()的结果。






不建议使用 mysql _ * 库。建议升级到MySQLi或PDO。


Possible Duplicate:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in select

i keep getting the error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL Result in line 40 on my webpage i dont know why.. please help me . Background: this script is to pull my database tables up named yname,username,password,date,comments,works,dworks the works and dworks are for people who tryed what came up and then they can judge if it works - yes it works dworks - no it dosent work its supposed to be voting sortof well forget about that my problem is on like 40 of this script please help me

<php require "br.htm" ?>
<style>
<?php require "styles.css" ?>
</style>
<?php

$host="host"; // Host name 
$username="name"; // Mysql username 
$password="pass"; // Mysql password 
$db_name="dbname"; // Database name 
$tbl_name="passes"; // Table name 

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// select record from mysql 
$sql="SELECT * FROM $tbl_name order by id desc";
$result=mysql_query($sql);
?>
<table background='https://lh6.ggpht.com/DFABQFuYSXLBiB6qlvDPfOONOUxCiwM6_S-dHnjW82iognQToTkORsy7RVXsAz0Y23w=w705' width='50%'>
<tr>
<th align='center'>Submition By</th><th align='center'>ScreenName</th><th align='center'>Password</th><th align='center'>Does This Work?</th>
</tr>
<tr>
<th align='center'>
<hr color='lime' width='100%'/>
</th>
<th align='center'>
<hr color='lime' width='100%'/>
</th>
<th align='center'>
<hr color='lime' width='100%'/>
</th>
<th align='center'>
<hr color='gold' width='100%'/>
</th>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>

<tr>
<td background='transparent' align='left'><i><b><? echo $rows['yname']; ?> </b></i></td>
<td background='transparent' align='center'><i><b><? echo $rows['username']; ?></b></i></td>
<td background='transparent' align='right'><i><b><? echo $rows['password']; ?></b></i></td>
<td background='transparent' align='right'><i><b>&nbsp;&nbsp;&nbsp;Yes<? echo $rows['works']; ?></b></i></td>
</tr>

<?php
// close while loop 
}
?>

</table>

<?php
// close connection; 
mysql_close();
?>
<center> 

i dont want to re-style the page but if i have to i will.. if you see what is wrong please make a post below and tell me what line its on and how to correct it please then ill come back and let u know if it works :) thank you

解决方案

This error means your query failed. mysql_query() returns false if an error occurred, you are then passing false to mysql_fetch_array() which is triggering the error message.

Your query could be failing due to a missing/wrong table or field. To see the detailed error, print out the result of mysql_error().


The mysql_* library is deprecated. It is recommended to upgrade to MySQLi or PDO.

这篇关于警告:mysql_fetch_array():提供的参数不是第40行中的有效MySQL结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆