我創建了一個名爲prod_det.php的頁面。該頁面顯示產品的詳細信息。下面是代碼。但它不起作用。當我點擊詳細信息按鈕警告接收錯誤消息:mysql_fetch_array()預計參數1是資源,布爾僅在關閉按鈕的彈出窗口中顯示產品詳細信息
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Product</title>
<link href="CSS/product.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
//Create the connection and select the DB
include('db_connect.php');
// Select records from the DB
$query = "SELECT p.prod_name, p.prod_photo, pr.prod_price, pr.prod_desc, pr.prod_brand, pr.prod_w_c
FROM tblproduct p
INNER JOIN tblretprod pr ON p.prod_id = pr.prod_id";
$result = mysql_query($query);
// Display records from the table ?>
<?php while ($row = mysql_fetch_array($result)): ?>
<div class="prod_box_big">
<div class="top_prod_box_big"></div>
<div class="center_prod_box_big">
<div class="product_img_big"><?= '<img height="100" width="100" src="Images/Products/'.$row['prod_photo'].'"/>'; ?>
<div class="thumbs"><?= $row['prod_desc']; ?></div>
</div>
<div class="details_big_box">
<div class="product_title_big"><?= $row['prod_name']; ?></div>
<div class="specifications">
Brand: <span class="blue"><?= $row['prod_brand']; ?></span><br />
Quantity: <span class="blue"><?= $row['prod_w_c']; ?></span><br />
Price include <span class="blue">TVA</span><br />
</div>
<div class="prod_price_big"><span class="reduce"><?= $row['prod_price']; ?> </span> <span class="price">%promo%</span></div>
<a href="#" class="addtocart">add to fav</a>
<a href="#" class="compare">compare</a>
</div>
</div>
<div class="bottom_prod_box_big"></div>
</div>
<?php endwhile; ?>
</body>
</html>
可能重複[Warning:mysql \ _fetch \ _array()期望參數1爲資源\ [... \]](http://stackoverflow.com/questions/5470533/warning-mysql-fetch-array -expect-parameter-1-to-resource) – mario
[mysql \ _fetch \ _array()的可能的重複需要參數1爲資源,布爾在select中選擇](http://stackoverflow.com/questions/2973202/ mysql-fetch-array-expects-parameter-1-to-resource-boolean-given-in-select) –
請參閱[本答案](http://stackoverflow.com/a/11674313/250259)瞭解如何解決這個問題。 –