您好我试图在交易后减去用户信用额度但更新时出现问题。测试accepted_bidder = 15且客户信用额度为100.由于某种原因我更新时为-14而不是75个人都知道为什么会这样?
输出:
object(mysqli_result)#2(5){[" current_field"] => INT(0) ["场计数"] => int(1)[" length"] => NULL [" num_rows"] => INT(1) ["类型"] => int(0)} int(15) 注意:第19行的C:\ xampp \ htdocs \ payment2.php中无法将类mysqli_result的对象转换为int
<?php
session_start();
require 'config.php';
$id = $_SESSION['login_user'];
$jobid = $_POST['job_id'];
$poster_id = $_POST['poster_id'];
$accepted_bidder = $_POST['accepted_bidder'];
$accepted_bid = (int) $_POST['accepted_bid'];
$poster_id = $_POST['poster_id'];
$query = "SELECT credit FROM `customer` WHERE email_adress = '$id'";
$result = $conn->query($query);
var_dump($result);
var_dump($accepted_bid);
$updated_credit = (int)$result - $accepted_bid;
//echo $updated_credit;
$query2 = "UPDATE job SET start_escrow = '1' WHERE job_id = '$jobid'";
$success = $conn->query($query2);
$query3 = " UPDATE customer SET credit = '$updated_credit' WHERE email_adress = '$id'";
$success3 = $conn->query($query3);
if (!$success) {
die("Couldn't enter data: ".$conn->error);
}
echo "Thank You For Contacting Us <br>";
//header("location: myjobs.php");
$conn->close();
?>