I am trying to return three values to my front end. My problem is (or at least I think) is that it is returning as a boolean. Here is my code:
<?php
require "../../inc/dbinfo.inc";
ini_set("log_errors", 1);
ini_set("error_log", "/tmp/php-error.log");
error_log( "################################################# FT-VENDOR-INVOICE-FILLOUT.PHP #################################################" );
$num = $_POST['num'];
$sql = $conn->prepare("SELECT COUNT(*) AS sq FROM tblVendorInvoices WHERE VendorPOID1 = ?");
$sql->bind_param("i",$num);
$sql->execute();
$hold = $sql->get_result();
$obj->sq = $hold->fetch_object();
$obj->sq = round($obj->sq,2);
$sql2 = $conn->prepare("SELECT POAmount AS poam FROM tblVendorPOs WHERE VENDORPOID = ?");
$sql2->bind_param("d",$num);
$sql2->execute();
$hold2 = $sql2->get_result();
$obj->poam = $hold2->fetch_object();
$obj->poam = round($obj->poam,2);
$sql3 = $conn->prepare("SELECT SUM(VdrInvoiceAmount) AS itd FROM tblVendorInvoices WHERE VendorPOID1 = ?");
$sql3->bind_param("d",$num);
$sql3->execute();
$hold3 = $sql3->get_result();
$obj->itd = $hold3->fetch_object();
$obj->itd = round($obj->itd,2);
echo json_encode($obj);
exit();
?>
My error log is reporting:
[01-Aug-2018 09:15:49 America/Toronto] ################################################# FT-VENDOR-INVOICE-FILLOUT.PHP #################################################
[01-Aug-2018 09:15:49 America/Toronto] PHP Warning: Creating default object from empty value in /var/www/html/fetch/ft-vendor-invoice-fillout.php on line 14
[01-Aug-2018 09:15:49 America/Toronto] PHP Notice: Object of class stdClass could not be converted to int in /var/www/html/fetch/ft-vendor-invoice-fillout.php on line 15
[01-Aug-2018 09:15:49 America/Toronto] PHP Notice: Object of class stdClass could not be converted to int in /var/www/html/fetch/ft-vendor-invoice-fillout.php on line 22
[01-Aug-2018 09:15:49 America/Toronto] PHP Notice: Object of class stdClass could not be converted to int in /var/www/html/fetch/ft-vendor-invoice-fillout.php on line 29
Current Response: {"sq":1,"poam":1,"itd":1}
Desired Response is this exact format but the numbers are wrong. They are queried values so I'm sorry I can't give an exact output. I've tried typecasting some of these lines but to no success. I don't really understand why I'm getting this int conversion error in my log so an explanation of that would be amazing. The first value should always be an in and the second and third should be float.
Also, I couldn't understand most of PHP docs explanations so please don't reference those.