2012-01-04 53 views
0

可能重複:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
mysql_num_rows(): supplied argument is not a valid MySQL result resource
Warning: mysql_fetch_* expects parameter 1 to be resource, boolean given errorSQL錯誤消息未知我: 「警告:mysql_num_rows():提供的參數不是一個有效的MySQL結果資源」

我想通過一個身份證,通過我收到我不知道的錯誤消息的網址。我的代碼如下:

<?php 

$result = mysql_query("SELECT * FROM Agendas INNER JOIN Meetings ON Meetings.meeting_id = Agendas.meeting_id WHERE approval = 'pending' ORDER BY Agendas.meeting_id DESC") 
or die(mysql_error()); 

if (mysql_num_rows($result) == 0) { 
     echo '<h2>No Action Is Required Yet</h2>'; 
    } else { 

while($info = mysql_fetch_array($result)) 
{ 

     echo "<tr>"; 
     echo "<td><br/>" .'Meeting Title: '. $info['title']." </td>"; 
     echo "<td><br/><br/>" .'<a href="viewagenda.php?agenda_id=' . $info['agenda_id'] . '">View Agenda</a> '." </td>"; 
     echo "<hr>"; 
     } 
    } 
echo "</tr>"; 
echo "</table>"; 


?> 

viewagenda.php如下:

<?php 
$id = $_GET['agenda_id']; 

$query = mysql_query("SELECT * FROM Agendas INNER JOIN Meetings ON Meetings.meeting_id = Agendas.meeting_id WHERE agenda_id = '$id'") 
or die(mysql_error()); 

if (mysql_num_rows($result) == 0) { 
     echo '<hr><h2>There Arent Any Agendas For This Meeting Yet</h2>'; 
    } else { 

while($info = mysql_fetch_array($result)) 
{ 

     echo "<tr>"; 
     echo "<td><br/>" .'Title: '. $info['title']." </td>"; 
     echo "<td><br/>" .'Subject: '. $info['subject']. "</td>"; 
     echo "<td><br/>" .'Duration: '. $info['duration']. "</td>"; 

     echo "<hr>"; 
     } 
    } 
echo "</tr>"; 
echo "</table>"; 
?> 

錯誤消息我得到的是:

「警告:mysql_num_rows():提供的參數不是E:\ webareas \ hj942 \ conference \ Chairperson \ viewagenda.php在線70'上的有效MySQL結果資源

我的表格如下:

會議:MEETING_ID,稱號,會長,祕書長,occurances

議程:agenda_id,主題,時間,MEETING_ID

+0

什麼是「\ viewagenda.php」中的第70行? – Robert 2012-01-04 16:47:58

+1

**請參閱右邊的相關專欄 - > ** – hakre 2012-01-04 16:52:17

回答

2

我猜你的意思是:

$result = mysql_query("SELECT * FROM Agendas INNER JOIN Meetings ON ... 

,因爲您使用的是$result變量mysql_num_rows

if (mysql_num_rows($result) == 0) { 
+0

感謝它現在的作品 – user1114080 2012-01-04 16:51:47

+0

+1爲我綁定第一個答案:) – 2012-01-04 16:53:01

1

$result從來沒有設置我n viewagenda.php因此不是MySQL資源。您設置了$query

將您的賦值語句更改爲以下代碼,其餘代碼應該可以工作。

$result = mysql_query("SELECT * FROM Agendas INNER JOIN Meetings ON Meetings.meeting_id = Agendas.meeting_id WHERE agenda_id = '$id'") 
+0

感謝它現在的作品 – user1114080 2012-01-04 16:51:18

1

在嘗試在viewagenda.php中應用mysql_num_rows()函數之前,$ result不存在。我認爲你的意思是$查詢。

這就是說,你也有SQL注入問題。在使用POST數據時,在查詢中使用它們之前,應該避開變量,,尤其是mysql_real_escape_string()將有所幫助。

+0

感謝它現在的作品 – user1114080 2012-01-04 16:50:43

0

它應該是if (mysql_num_rows($query) == 0)

+0

感謝它現在的作品 – user1114080 2012-01-04 16:51:27

相關問題