and because of this you don' t need to give them any conditions. Remove the ´ in the line $ contador = ( $ ln[ ' valor_ almoco' ] - 8. To debug such errors look at the line number in the error message. This script won' t work since javascript is client side and php is server side and it will only print/ alert as text not parse as php script.