2012-12-27 17 views
1

可能重複:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in select警告:mysql_fetch_array():提供的參數是不符合一個有效的MySQL結果40

我不斷收到錯誤 警告:mysql_fetch_array():提供的參數是不是在我的網頁40行 有效的MySQL結果我不知道爲什麼..請幫助我。 背景:這個腳本是拉我的數據庫表中一個名爲yname,用戶名,密碼,日期,評論,作品,DWORKS 作品和DWORKS是誰tryed什麼來了人,然後他們才能判斷它是否 作品 - 是的它的工作原理 DWORKS - 沒有它dosent工作 它應該是投票sortof也忘了,我的問題是這樣的劇本40,請幫我

<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> 

我不想重新風格的頁面,但如果我必須我會...如果你看到什麼是錯的,請在下面寫一個帖子,告訴我它的上線和如何糾正它,然後生病回來,讓你知道它是否工作:)謝謝

+0

先搜索,詢問後。 –

回答

4

此錯誤表示您的查詢失敗。 mysql_query()返回false如果發生錯誤,你再傳遞到falsemysql_fetch_array()是觸發錯誤消息。

您的查詢可能會因爲被遇事缺少/錯誤的表或字段。要查看詳細的錯誤,請打印出mysql_error()的結果。


mysql_*庫已棄用。建議升級到MySQLi或PDO。

+0

更改此行'$結果= mysql_query($的SQL);'到'$結果= mysql_query($的SQL)或死亡(mysql_error());',以驗證它是你的查詢 – Toby

+0

感謝託比我理解了它我已經ID命名#在數據庫中出於某種原因:) – TheWhiteHatter

相關問題