我完全糊涂了 我的整页代码都在下面
最初, 我拥有包含页眉. php、 侧边栏、 顶部MenuBar、 amp; 主 ContentShell 在页面顶部, 运行首个查询, 之后又运行第二个查询, 其余部分的第二个查询等 。 我的第一个查询效果不同... 我检查了$_ GET[ stone] 数字大于零, 低于所选择的最大值( StoneID), 但是如果有人手动将一个从库存中删除的石头放进StonID, 我仍然能得到错误 。 我修改了我的$_ GET 验证计划, 并将其移到包含的文件之上, 使页眉( ) 重新定向能够正常工作 。 现在, 我的第二个查询即使完全没有改变, 也不会成功 。
Var_dump($querySN) yields string(53) "select StoneName from stonetypes where StoneID = 1 " and var_dump($resultSN) yields NULL. It states: error occurred at line 35 --- $resultSN = $db->query($querySN); States several times: Couldn t fetch mysqli States a number of times: Property access is not allowed yet And states in conclusion: Call to a member function fetch_assoc() on a non-object on line 36---$rowSN = $resultSN->fetch_assoc();
有人知道这是怎么回事吗?
<?php
require( ./inc/config.inc.php );
$stone = (INT)$_GET[ stone ];
require(MYSQL1);
$queryCk = "select StoneID from stonetypes";
$resultCk = $db->query($queryCk);
$var = array();
while ($rowCk = $resultCk->fetch_assoc()){
$var[] = $rowCk[ StoneID ];
}
if(!in_array($stone, $var)) {
header( Location: beadgallery.php?type=stones );
exit;
} else {
include( inc/header.inc.php );
include( inc/sidebar.inc.php );
include( inc/topMenuBar.inc.php );
include( inc/mainContentShell.inc.php );
?>
<div id="mainContent">
<div class="center">
<?php
$querySN = "select StoneName from stonetypes where StoneID = $stone ";
$resultSN = $db->query($querySN);
$rowSN = $resultSN->fetch_assoc();
echo <table id="cartDisplayTable"> ;
echo <tr> ;
echo <td colspan="2"> ;
echo <table id="titleTable"> ;
echo <tr> ;
echo <td id="stoneTitle"> ;
if (isset($rowSN[ StoneName ])){
echo <h2> .ucwords($rowSN[ StoneName ]). </h2> ;}
echo </td> ;
echo </tr> ;
$query = "select * from organized_inventory2 where StoneID = $stone ";
$result = $db->query($query);
$num_beadItems = $result->num_rows;
$justused= abc ;
for ($i=0; $i < $num_beadItems; $i++) {
$row = $result->fetch_assoc();
if (!isset($row[ itmphoto ])) {
echo </table> ;
echo </td> ;
echo </tr> ;
echo <tr><td colspan="2"><hr id="cartDivider"></td></tr> ;
echo <tr> ;
echo <td id="cartImgCell"> ;
echo <img src="img/nophoto.gif"> ;
echo </td> ;
echo <td id="cartInfoCell"> ;
echo <table id="innerTable"> ;
include ( inc/stoneCartInfo.inc.php );
} elseif ($row[ itmphoto ] == $justused) {
echo <tr><td colspan="2"><hr id="itemDivider"></td></tr> ;
include ( inc/stoneCartInfo.inc.php );
} else {
echo </table> ;
echo </td> ;
echo </tr>
;
echo <tr><td colspan="2"><hr id="cartDivider"></td></tr>
;
echo <tr> ;
echo <td id="cartImgCell"> ;
echo <img src="img/invent/ .$row[ itmphoto ]. "> ;
$justused = $row[ itmphoto ];
echo </td> ;
echo <td id="cartInfoCell"> ;
echo <table id="innerTable"> ;
include ( inc/stoneCartInfo.inc.php ); }
}
echo </table>
;
echo </td> ;
echo </tr>
;
echo </table>
;
}
$result->free();
unset($result);
$db->close();
?>
</div> <!-- div class="center" -->
</div> <!-- div id="mainContent" -->