php - ErrorException [ Parse Error ]: syntax error, unexpected T_ENDIF -


i want validate or show radio button checked,if value present in database. please refer views code,

<input type="radio" name="bothadvandlor"  value="1" <?php if($advs->is_checked == "1");?>checked="checked"<?php endif;?> class="advs"/> show google ads<br/> <input type="radio" name="bothadvandlor"  value="2" <?php if($advs->is_checked == "2");?>checked="checked"<?php endif;?> class="advs"/> others 

the above form tried,but getting syntax error message "errorexception [ parse error ]: syntax error, unexpected t_endif" .

need solve this.

you need use colon : instead of semi-colon ; here after if condition:

if($advs->is_checked == "1"): // -----------------------  ^ here  if($advs->is_checked == "2"): // -----------------------  ^ , here    

from docs:

php offers alternative syntax of control structures; namely, if, while, for, foreach, , switch. in each case, basic form of alternate syntax change opening brace colon (:) , closing brace endif;, endwhile;, endfor;, endforeach;, or endswitch;, respectively.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -