HOW TO SOLVE Notice: Undefined index: IN PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KeyraRa
    New Member
    • Aug 2014
    • 5

    #1

    HOW TO SOLVE Notice: Undefined index: IN PHP

    hello guys.. i have a problem..can anyone tell me how to solve this:

    Notice: Undefined index: BMK81A in C:\
    2) Incorrect integer value: '' for column 'BMK81A' at row 1
    3) Notice: Undefined index: BMK81 in C:
    4) Notice: Undefined index: DL3 in C: and so on



    here my code:

    Code:
    $IC2= $_SESSION['IC2'];
            $BMK81A = $_POST['BMK81A'];
            $BMK81 = $_POST['BMK81'];
            $DL3 = $_POST['DL3'];
            $DL2 = $_POST['DL2'];
            $DL1 = $_POST['DL1'];
            $S1 = $_POST['S1'];
            $S2 = $_POST['S2'];
            $S3 = $_POST['S3'];
            $S4 = $_POST['S4'];
            $S5 = $_POST['S5'];
            $S6 = $_POST['S6'];
            $S7 = $_POST['S7'];
            $D1 = $_POST['D1'];
            $A1 = $_POST['A1'];
            $RE1 = $_POST['RE1'];
            $LU2 = $_POST['LU2'];
            $NPT = $_POST['NPT'];
            $SRP = $_POST['SRP'];
            $KTDP = $_POST['KTDP'];
            $KDP = $_POST['KDP'];
            $USPD = $_POST['USPD'];
    $query = " UPDATE  doku SET BMK81A='$BMK81A', BMK81='$BMK81', DL3='$DL3', DL2='$DL2', DL1='$DL1', S1='$S1', S2='$S2', S3='$S3', S4='$S4', S5='$S5', S6='$S6', S7='$S7', D1='$D1', A1='$A1', RE1='$RE1', LU2='$LU2', NPT='$NPT', SRP='$SRP', KTDP='$KTDP', KDP='$KDP', USPD='$USPD' WHERE NO_KPT2='$IC2' ";
    mysql_query($query) or die(mysql_error());

    - i'm doing a checkboxes.. if i select a checkboxex, then it will insert into database. then it should update data in the database if have any changes made..
    - in database, i'm doing a default value..if selected it will be become 1, if not selected will become 0. so from this, i want to update in the database..how to make it?
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    use function isset() for every array like ( i.e. line#2):
    Code:
    if (issset($_POST['BMK81A']) { 
      $BMK81A = $_POST['BMK81A'];
    } else {
      $BMK81A = "no value given for this one";
    }

    Comment

    • amnos
      New Member
      • Oct 2014
      • 3

      #3
      Code:
      //First assign default value for all variables
      $BMK81A = 0;
      $DL3=0;
      //Check the value is posted by post method if it is assign it to the corresponding value
       if (isset($_POST['BMK81A']) { 
        $BMK81A = $_POST['BMK81A'];
       }
         
       if(isset($_POST['DL3'])){
       	$DL3=$_POST['DL3'];
       }
      Like wise do this for all the variables for which you are getting notice error.

      Comment

      Working...