Error from sum operation

Sir suddenly I am facing this error message


and php file has these codes

<?php
date_default_timezone_set("Asia/Karachi");
$tstamp = date('Y-m-d H:i:s');

//--------------------------------------------------------------------------

$client_ip = $_SERVER['REMOTE_ADDR'];
$mac_address = exec('getmac');
$mac_address = strtok($MAC, ' ');
//echo $mac_address;
//--------------------------------------------------------------------------
// database credentials
//--------------------------------------------------------------------------
$servername = "localhost";
$username = "id20649282_hassan";
$password = "Tariq@123456";
$database = "id20649282_asiacng";
$dbc = mysqli_connect($servername, $username, $password, $database);
if (!$dbc) {
    die("DATABASE CONNECTION FAILED:" . mysqli_error($dbc));
    exit();
}
//--------------------------------------------------------------------------
// variables
//---------------------------------------------------------------------------
$datex = mysqli_real_escape_string($dbc, $_GET["date"]);
$button = mysqli_real_escape_string($dbc, $_GET["button"]);
 // echo $button;

//-------------------------------------------------------------------------------------
// DAILY purchase
//-------------------------------------------------------------------------------------
// on screen initilize

if ($button =="btn_stock_pet") {
$query = "Select data.ddate,
	SUM(ifnull(data1.opening+data1.P_Pur-data1.P_sal,data.opening)) As opening,
	data.P_Pur As p_ltr,
	data.P_sal As P_sal,
	SUM(ifnull(data1.opening+data1.P_Pur-data1.P_sal,data.opening))+(data.P_Pur-data.P_sal) As closing
	FROM (
        Select ddate, Sum(p_ltr) As opening, 0 As P_Pur,0 As P_sal
	FROM master1 Group By ddate
	union All
	SELECT ddate, 0 As opening, Sum(p_ltr) As P_Pur,0 As P_sal From purchase Group By ddate
	UNION All
	SELECT ddate, 0 As opening, 0 As P_Pur,Sum(p_ltr) As P_sal From sales Group By ddate)
    As data
	LEFT Join (
        Select ddate, Sum(p_ltr) As opening, 0 As P_Pur,0 As P_sal FROM master1 Group By ddate
	union All
	SELECT ddate, 0 As opening, Sum(p_ltr) As P_Pur,0 As P_sal From purchase Group By ddate
	UNION All
	SELECT ddate, 0 As opening, 0 As P_Pur,Sum(p_ltr) As P_sal From sales Group By ddate)
	as data1
    On data1.ddate < data.ddate
	GROUP By data.ddate,data.P_Pur,data.P_sal";
  
$hacer = mysqli_query($dbc, $query);
$numColumns = mysqli_field_count($dbc);

if ($numColumns > 0) {
    $en_csv = '';
    while ($row = mysqli_fetch_assoc($hacer)) {
        foreach ($row as $column) {
            $en_csv .= $column . ",";
        }
        $en_csv = rtrim($en_csv, ",");
        $en_csv .= "\n";
    }
    $en_csv = rtrim($en_csv, "\n");
    
   
    print $en_csv;
}
 mysqli_close($dbc);
}

?>

Sir what kind of issue is this?

Please help

As shown in the error message, you're supplying incorrect arguments to the sum operation. Try do it on each sum operation, and see which one throws the error.

To fix this type of error, it is best to simplify the code, in this case, in a Label, obtain the responseContent data and see if you get what you expect, if you do not get what you want, the error may be in the PHP code .

dsdsdsdsww

2 Likes

Sir I tested with label1 like this

and Companion is showing this data

The red box is label1

So I am confuse where is error?

Regards

Please try doing what I initially asked you to do (so we can narrow the error down).

in your dataList you have a Header. which can not caculated as a number.

1 Like

Sir do you mean this part
hh1

Should I remove this block?

Regards

you only show part of your code, si we have to guess .

1 Like

Sir this is complete set of blocks

Regards

it looks fine for me. did you remove the error message before try again?

1 Like

Yes I removed but error message is still on its place.
Regars

Working OK here

t_tableViewer_revisedV3.aia (27.9 KB)

1 Like

Respected Sir,

Thank you very much for helping me but
I show you the problem is still alive


The upper partition is label.text

How error comes? this is screen recording
https://www.veed.io/view/282a1cd3-b6b1-42a1-a42c-eca00f02756a?sharingWidget=true&panel=

I am amazing data is appearing correctly on companion but there is error also on DO IT.

Regards

Is that with the AIA I just uploaded,?

Cannot view your video.

1 Like

Yes Sir sure. You may check the project name in Video

Regards

do you mean after you get text from web then run do it manually?

if so, of course you will get error , since you already add a header in the datalist.

1 Like

Yes boss the error appears after displaying data in companion.

The resetting of the variable from response content should negate that.

However, if the OP is uploading and replacing the data with the dataList in their mySQL, then they need to remove the headers row first (and the Totals row).

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.