gpt4 book ai didi

MySQL 问题 - 警告 : mysql_num_rows() expects parameter 1 to be resource, bool 值给出

转载 作者:行者123 更新时间:2023-11-29 11:56:33 24 4
gpt4 key购买 nike

需要了解错误,我需要修复错误,以便显示数据库中的车辆。这是 bool 值,为什么它不起作用这是 9 个月前网站的备份。如果有人可以帮助我,请告诉我

               </div>

<?php if(isset($_GET['dmsg']) && $_GET['dmsg']==1) { echo '<div align="center" style="color:green; font-weight:bold;">vehicles Deleted successfully..</div>';} ?>
<a href="insert-vehicles.php" style=" background: none repeat scroll 0 0 green; color: white; float: right; margin: 0 20px 0 0; padding: 10px;">Insert new Vehicles</a>
<div class="offer_area">

<div class="offer_head row">

<form action="" method="get" name="form1" class="key_form">

<label>Keyword :(search by Make, Model, Year, Stock no)</label>

<input name="keyword" type="text" value="<?php if($_GET['keyword']) {echo $_GET['keyword']; } ?>"/>

<input name="search" class="search" type="submit" value="search" />

</form>

</div>
<br />
<br />
<br>
<br>
<table width="90%" align="center" cellpadding="2" cellspacing="0">
<tr>
<th scope="col">IMAGE</th>
<th scope="col">STOCK NUMBER</th>
<th scope="col">MAKE</th>
<th scope="col">MODEL</th>
<th scope="col">YEAR</th>
<th scope="col">AUCTION DATE</th>
<th scope="col">SALE DOCUMENT</th>
<th scope="col">CURRENT BID PRICE</th>
<th scope="col">BUY NOW PRICE</th>
<th scope="col">ACTION</th>
</tr>
<?php
$id=1;
while ($GetUserQryRow = mysql_fetch_array($GetUserQryRs)) {
?>
<tr>
<td align="center"><img src="<?php echo $GetUserQryRow['defaultImg']; ?>" width="96"/> </td>
<td align="center"><?php echo $GetUserQryRow['StockNumber']; ?> </td>
<td align="center"><?php echo $GetUserQryRow['Make']; ?></td>
<td align="center"><?php echo $GetUserQryRow['Model']; ?> </td>
<td align="center"><?php echo $GetUserQryRow['Year']; ?></td>
<td align="center"><?php echo date('m, d Y H:i:s A',strtotime($GetUserQryRow['LiveAuctionDate'])); ?> </td>
<td align="center"><?php echo $GetUserQryRow['SaleDocument']; ?> </td>
<td align="center"><?php if(is_numeric($GetUserQryRow['CurrentBidPrice'])){ echo number_format($GetUserQryRow['CurrentBidPrice'],2); } ?> </td>
<td align="center"><?php if(is_numeric($GetUserQryRow['ibuyCost'])){echo number_format($GetUserQryRow['ibuyCost'],2); } ?> </td>
<td align="center"><a href="edit-vehicles.php?id=<?php echo $GetUserQryRow['StockNumber']; ?>">Update</a>&nbsp;&nbsp;<a href="javascript:void(0);" onclick="confirmdel('<?php echo $GetUserQryRow['StockNumber']; ?>');">Delete</a> </td>
</tr>
<?php $id++; } ?>
</table>




</div>



<?php include('sections/footer.php'); ?>

</div>

<p>&nbsp;</p>
</body>

</html>

最佳答案

问题在于,当您使用 mysql_query() 发出 sql 查询时,您的代码中绝对没有错误处理。您应该通过检查每个 mysql_query() 的返回值来添加错误处理,并记录/显示使用 mysql_error() 遇到的任何错误消息。

$res=mysql_query(...);
if($res) {
//do your normal stuff
}
else {
echo mysql_error();
//decide to stop or render futher parts of the website
}

根据 mysql 错误消息,您可以解决您遇到的问题。然而,我的猜测是,与数据库的连接有缺陷。密码、用户名或主机名错误。

编辑:请注意 mysql_*() 函数已处于弃用状态,并且它们的支持将从 php7 中删除。转换为 mysqli 或 PDO。

关于MySQL 问题 - 警告 : mysql_num_rows() expects parameter 1 to be resource, bool 值给出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33111223/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com