I am getting this error when trying to subtract one value from another to create a new value to return to a database. Help would be most a Kind!😕

Code:

/ Get the currQty of Inventory item and set it as old Take off used stock and post back to the database table invitems/

			$oldQty=$row_Recordset2['currQty_invItem'];
			$usedQty=$_GET['qty_servInv'];
			$newQty= $oldQty - $usedQty;

endCode:

The error is on the last line.

    array(2) { [1]=> string(2) "10" [2]=> string(2) "60" } 60

    Sorry for the delay been busy.

    This is the output from the Form $usedQty

    array(2) { [1]=> string(2) "10" [2]=> string(2) "60" } NULL 60

    This is the output from both $usedQty (form) and $ OldQty (datbase, query)

    Thanks!

    I have not come across this error before, I noticed a null value in the string from the query, would that have any effect?

    😕

      Sorry, it's not clear what the 60 NULL 60 on the end there are. But if array(2) {...} is what you get from var_dump($oldQty) and var_dump($usedQty) then it's only to be expected that you get an error, because you're trying to subtract arrays from each other.

        Thinking about it you are right I am trying to subtract one array from another.

        item 1 $usedQty (5) - $oldQty (2) = $newQty

        I have not done this before so from your note I guess I can not! What would you recommend would be the best way to handle this. I am trying to update an inventory table but with more than one item being consumed at once.

        It is for servicing, so filers, lubes are all consumed, I am getting the current quantity and taking off the used amount.

        Thanks for your help
        :rolleyes:

          Write a Reply...