在我的详细视图页面上,并在 URL 栏中获取正确的 ID,如下所示:
http://localhost/attractions/details.php?ID=1
我的页面标题和侧边栏已加载,但在我想要记录详细信息的空间中,我收到以下错误消息:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/attractions/details.php on line 41
这是“details.php”页面代码(删除了不必要的 html):
<?php
include 'page-start.php';
$myQuery = "SELECT Attraction.*, Type.TypeName ";
$myQuery .= "FROM Attraction ";
$myQuery .= "INNER JOIN Type ON Attraction.Type = Type.TypeID";
$myQuery .= "WHERE AttractionID=" . $_GET['ID'];
$result = mysql_query($myQuery);
if (!result) {
die('Query error: ' . mysql_error());
}
?>
<body>
<div class="container">
<h2>List of Attractions</h2>
<?php
//display attractions row by row
while($row = mysql_fetch_array($result))
{
echo '<div class="attraction">';
echo '<h4><a href="details.php?ID=' . $row['AttractionID'] . '">' . $row['Name'] . '</a></h4>';
echo '<div class="featureimage">';
echo '<img src="'. $row['ImageUrl'] . '" />';
echo '</div>';
echo '<p>' . $row['TypeName'] . '</p>';
echo '<h5>' . $row['Summary'] . '</h5>';
echo '</div>';
}
?>
</div><!-- container -->
</body>
</html>
<?php
include 'page-end.php';
?>
第 41 行是这一行:
while($row = mysql_fetch_array($result))
我只知道我会在这里忽略一些如此简单的事情,但是我很困惑,我真的无法弄清楚是什么导致了错误,请有人能对我的情况有所了解,我已经搜索过类似的问题,但是没有人可以帮助我!