我已经将我的网站从mysql切换到mysqli并遇到了挑战。我已经在下面列出了脚本崩溃的相关文本。我有与原始mysql查询完全相同的文本,这没有问题,但是当我切换时," // IPN之后的部分没有处理"返回以下错误:
Call to a member function fetch_assoc() on a non-object
我已经读过这可能是因为查询失败了,但是在使用旧查询进行测试时它仍然有用,我想知道是否有人可以看到我可能忽略的明显错误。谢谢!
$confirmation = urldecode($httpParsedResponseAr['INVNUM']);
$txn_id = urldecode($httpParsedResponseAr["PAYMENTREQUEST_0_TRANSACTIONID"]);
$payment_gross = urldecode($httpParsedResponseAr['PAYMENTREQUEST_0_AMT']);
// Verify that the order has not yet been processed (IPN/PDT)
$sql = "SELECT COUNT(*) FROM stix_".$sitemode."_orders WHERE txn_id = '$txn_id'";
$result = $connect->query($sql);
if (!$result) {
error_log(mysqli_error());
exit(0);
}
$row = $result->fetch_row();
$exists = $row[0];
$result->free();
if (!$exists) {
// IPN has Not Processed
$sql = "SELECT SUM(order_total) AS order_total FROM stix_".$sitemode."_cart WHERE confirmation = '$confirmation'";
$result = $connect->query($sql);
while($row = $result->fetch_assoc()){}
}