Trying to declare an IP using a variable

You should do this:

IPAddress ip(192,168,2,y);

The value of

(192,168,2,y)

is simply y, because you're using the comma operator. So you're saying: ip = y
My version says "call the constructor for IPAddress with 4 values"

Also, should y be 145?