Catchable fatal error: Object of class mysqli_result could not be converted to string in [duplicate]

StackOverflow https://stackoverflow.com/questions/21647008

  •  08-10-2022
  •  | 
  •  

Question

i want create verify page from my ebank, e bank send bellow parameters :

$Status = $_POST['status'];
$Refnumber = $_POST['refnumber'];
$Resnumber = $_POST['resnumber'];
        $res = $client->VerifyPayment(array("MerchantID" => $MerchantID , "Password" =>$Password , "Price" =>$Price,"RefNum" =>$Refnumber ));
$Status = $res->verifyPaymentResult->ResultStatus;
$PayPrice = $res->verifyPaymentResult->PayementedPrice;

i want add Amount to user data base with bellow code :

    $MerchantID = 'xxxxx';
$Password = 'xxxxx';




if(isset($_POST['status']) && $_POST['status'] == 100){



    $Status = $_POST['status'];
    $Refnumber = $_POST['refnumber'];
    $Resnumber = $_POST['resnumber'];
    $price = $db2->query("SELECT `price` FROM `user_payments`  WHERE `invoice_number` = '$Resnumber'");

    $client = new SoapClient('http://merchant.parspal.com/WebService.asmx?wsdl');       
    $res = $client->VerifyPayment(array("MerchantID" => $MerchantID , "Password" =>$Password , "Price" =>$Price,"RefNum" =>$Refnumber ));
    $Status = $res->verifyPaymentResult->ResultStatus;
    $PayPrice = $res->verifyPaymentResult->PayementedPrice;

    $db2->query("UPDATE `user_payments` SET `done` = '1' , `refid` = '$Refnumber' WHERE `invoice_number` = '$Resnumber'");
    $new_balance = $this->user->info->balance + $PayPrice;
    $uid = $this->user->info->id;
    $fee = $PayPrice;
    $time = time();
    $db2->query("UPDATE `users` SET `balance` = '$new_balance' WHERE `id` = '$uid' ");
    $db2->query("INSERT INTO `user_balance_report` (`uid`,`type`,`fee`,`msg`,`date`)VALUES('$uid','3','+".$fee."','your code: ".$Resnumber."','$time')");
    $D->user_purchase = "success <br>cost $fee Added in your account.";
    $this->user->sess['LOGGED_USER'] = $this->network->get_user_by_id($this->user->id, TRUE);
    $this->user->info = & $this->user->sess['LOGGED_USER'];
    }

but i have see this code when back from bank : Catchable fatal error: Object of class mysqli_result could not be converted to string in this line :

        $res = $client->VerifyPayment(array("MerchantID" => $MerchantID , "Password" =>$Password , "Price" =>$Price,"RefNum" =>$Refnumber ));
Was it helpful?

Solution

i should be used

$price = $db2->fetch_field("SELECT `price` FROM `user_payments`  WHERE `invoice_number` = '$Resnumber'");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top