Getting UndefVarError even though variables are defined

Even when I define p I still get the error