I'm not entirely sure why you think you even need the if statement in that first section of code - update is perfectly capable of selecting the records for you:
UPDATE polje
SET tezina = tezina + 1
WHERE xkoord = 0 AND ykoord = 0;
That will only hit rows where both coordinates are zero. If there are none, then no rows will be modified.
However, if your intent is to detect whether a row exists so you can either insert or update it (as your edit seems to suggest), the normal way of doing that is with insert ... on duplicate key ....
In your particular case, that would be something along the following lines, assuming the primary key was a composite over the coordinate columns:
INSERT INTO polje (
xkoord, ykoord, tezina, d_tezina
) VALUES (
x, y, tezina, tezina
) ON DUPLICATE KEY
UPDATE tezina = tezina + 1
Another possibility, if you don't have your primary key set up that way, is to do the update and detect if you hit any rows. If so, you're done, otherwise you need to insert a row.
The update in that case would be identical to the first one shown above. Then you simply check row_count() to see if the rows updated was zero. If it was, you then insert the first new row for this coordinate pair.
Keep in mind that the definition of "rows updated" depends on how you connect. If you connect with the option CLIENT_FOUND_ROWS, the count is the number of rows touched regardless of the current row value (count is how many rows matched the where clause).
Without that, you only get a count of the rows that were actually changed to something new.
By that, I mean, consider you have two rows:
id value
-- -----
1 A
2 B
and you run update tbl set value = 'A'
The first time you run it without CLIENT_FOUND_ROWS, row count will be set to one since only id 2 is updated. If you run it again, you'll get a row count of zero since no rows are updated.
With CLIENT_FOUND_ROWS, you'll get a row count of two no matter how many times you run it, since it's giving you the rows matched by the where clause.
Also note that the update/detect/insert should be done within a transaction to ensure no race conditions.