Error Unsupported operand types [closed]

1

When I import the property xml it does the account according to the criteria. One of the criteria is the price, the most expensive ones appear first, for this I divided the value of the price by 10 million and adds the result in his ranking.

Ex: Real estate with 1500 + rating (price of 10,000,000 / 10,000,000) = 1501

But when I do this, it crashes the import and gives this error:

  

Error Unsupported operand types on line 332

What is the line where the if of the code ends:

if ($tipo==Venda){
$ordem = $ordem + $preco/10000000;
}

Does anyone know what might be happening?

    
asked by anonymous 24.05.2017 / 22:19

1 answer

2

To "debug" the variables, before if do:

var_dump($ordem, $preco);
if ($tipo==Venda){

And then you will notice the problem, $ordem or $preco are not numbers , one of them must be array or null and then it will not be possible to do the math operation, which causes the error.

This should be occurring because you are using a while or for without checking the values being used added to $ordem and $preco , you may also be using the variable in different places, type trying reuse a variable to do two things, something that can really cause a lot of problems.

Another problem, which may not have a direct connection, is if that "seems" to be wrong:

if ($tipo==Venda){

The Venda would have to be 'Venda' , unless the sale is a constant (but this is another problem).

    
24.05.2017 / 22:22