I am getting this error when I run the following code:
PHP Fatal error: Uncaught Error: Call to undefined function mysqli_result() in chk_discount.php:21
Here's the full code:
<?php
include 'client_config.php';
foreach($_GET as $key => $value) {
$get[$key] = filter($value);
}
$total = base64_decode($_GET['total']);
echo calculate_discount($_GET['code'],$total);
function calculate_discount($code, $total) {
global $con;
if ($code && $total) {
$now = time();
list($discount_offer_on_totals) = mysqli_fetch_row(mysqli_query($con, "select discount_offer from orders_discounts"));
if ( $total < $discount_offer_on_totals ) {
return "Order total must be ".$curr_symbol. ' '. $discount_offer_on_totals." or more to qualify for discount!";
}
// check if code is valid and return result
$sql = @mysqli_query($con, "SELECT * FROM orders_discounts WHERE codex = '$code' AND expiry > $now AND status = 1 AND $total > discount_offer");
if (@mysqli_num_rows($sql) == 0) {
return "Invalid coupon code. Please try again.";
} else {
return mysqli_result($sql, 0, "percentage");
exit();
}
} else {
return "Invalid request! Please enter correct code. ";
}
}
?>
How should I edit the code?