Search code examples
phpcodeigniter

how i can solve this error "A PHP Error was encountered"?


Please give some idea. how to solve the error?

        echo "<td class='bold'>Race Category<span class='star'>*</span></td>";
    $array_all=array('name'=>'race_category','value'=>$s_race_category,'type'=>'RACE_CATEGORY','style'=>"class='selectbox'",'javascript'=>'','default'=>'');
    echo "<td>";
    echo $this->model_students->getAll($array_all);
    echo "</td>";

The error:

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: s_race_category
Filename: templates/forms.php
Line Number: 46

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: s_programme
Filename: templates/forms.php
Line Number: 124

Solution

  • The severity says "Notice", meaning they won't break your page but they indicate something else. In this case you probably haven't defined your variables before you use them.

    try assigning a value to the variables like:

    $s_race_category = "";
    $s_programme = "";
    

    You are seeing these notices because of the PHP error reporting level, you can read more about it here