2017-02-28 1 views
0

필자가 작성한 코드에서 135-154 행에 여러 개의 정의되지 않은 인덱스 오류가 발생했습니다 ... 필자는 125-130 행에 필요한 변수를 정의했음을 확신합니다. 이 문제와 관련된 다른 질문을 확인했지만 관련 정보를 찾을 수 없습니다. 아무도 왜 이러한 변수를 정의하더라도 왜 아직도이 오류가 발생하는지 설명 할 수 있습니까? 어떤 도움이라도 대단히 감사합니다.존재하는 코드는 정의되지 않은 것으로 나열되어 있습니까?

편집 : 내가 갖는 오류 메시지가 : 공지 사항 : 정의되지 않은 인덱스 : C에서 문법 : \ xamppnew \ htdocs를 \ loginSignup \ teachersPage.php 라인 (133)

공지 사항 : 정의되지 않은 인덱스 : 읽기 에서 C : \ xamppnew \ htdocs를 \ loginSignup \ teachersPage.php 라인 134

주의 : 정의되지 않은 인덱스 : C 쓰기 : \ xamppnew \ htdocs를 \ loginSignup \ teachersPage.php 라인 135

공지 : 정의되지 않은 색인 : 듣기 라인 \ xamppnew \ htdocs를 \ loginSignup \ teachersPage.php 136

통지서 : C에 보내고 불확정 지수 : C 말하는 \ xamppnew \ htdocs를 \ loginSignup \ teachersPage.php 라인 (137)에

공지 : 정의되지 않은 인덱스 : C의 평가 : \ xamppnew \ htdocs를 \ loginSignup \ teachersPage.php 라인 138

공지 : 라인 150에

\ xamppnew \ htdocs를 \ loginSignup \ teachersPage.php : 정의되지 않은 변수 : C의 평가

알림 : 정의되지 않음 ndex : C의 진행 :

<?php require_once('Connections/connection.php'); ?> 
    <?php 
    session_start(); ?> 
    <?php 
    if (!function_exists("GetSQLValueString")) { 
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    { 
    if (PHP_VERSION < 6) { 
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; 
    } 

    $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); 

    switch ($theType) { 
    case "text": 
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; 
     break;  
    case "long": 
     case "int": 
     $theValue = ($theValue != "") ? intval($theValue) : "NULL"; 
    break; 
    case "double": 
    $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; 
    break; 
    case "date": 
     $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; 
     break; 
    case "defined": 
    $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; 
     break; 
     } 
     return $theValue; 
     } 
      } 

     $editFormAction = $_SERVER['PHP_SELF']; 
     if (isset($_SERVER['QUERY_STRING'])) { 
     $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); 
     } 

     if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "TestResults")) { 
     $insertSQL = sprintf("INSERT INTO test_results (gt, grammar, Fname, Lname, reading, writing, speaking, listening, overall) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)", 
        GetSQLValueString($_POST['gt'], "int"), 
        GetSQLValueString($_POST['grammar'], "text"), 
        GetSQLValueString($_POST['Fname'], "text"), 
        GetSQLValueString($_POST['Lname'], "text"), 
        GetSQLValueString($_POST['reading'], "text"), 
        GetSQLValueString($_POST['writing'], "text"), 
        GetSQLValueString($_POST['speaking'], "int"), 
        GetSQLValueString($_POST['listening'], "int"), 
        GetSQLValueString($_POST['overall'], "int")); 

       mysql_select_db($database_connection, $connection); 
       $Result1 = mysql_query($insertSQL, $connection) or die(mysql_error()); 
       } 

      mysql_select_db($database_connection, $connection); 
      $query_Recordset1 = "SELECT * FROM test_results"; 
      $Recordset1 = mysql_query($query_Recordset1, $connection) or die(mysql_error()); 
      $row_Recordset1 = mysql_fetch_assoc($Recordset1); 
      $totalRows_Recordset1 = mysql_num_rows($Recordset1); 

      mysql_select_db($database_connection, $connection); 
      $query_Recordset2 = "SELECT * FROM test_results"; 
      $Recordset2 = mysql_query($query_Recordset2, $connection) or die(mysql_error()); 
      $row_Recordset2 = mysql_fetch_assoc($Recordset2); 
      $totalRows_Recordset2 = mysql_num_rows($Recordset2); 

      $query_Recordset1 = "SELECT * FROM test_results"; 
      $Recordset1 = mysql_query($query_Recordset1, $connection) or die(mysql_error()); 
      $row_Recordset1 = mysql_fetch_assoc($Recordset1); 
      $totalRows_Recordset1 = mysql_num_rows($Recordset1); 
     ?> 

     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     <html xmlns="http://www.w3.org/1999/xhtml"> 
     <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
     <title>Teacher's Page</title> 
     <link href="insert.php" rel="stylesheet" type="text/php"/> 
     <link href="ssmenu.css" rel="stylesheet" type="text/css"/> 
     <link href="sslayout.css" rel="stylesheet" type="text/css"/> 
     <style type="text/css"> 
     .boxed { 
     margin: auto; 
     padding: 2px; 
     height: auto; 
     width: 160px; 
     border: medium solid #000; 
     font-size: 20px; 
     } 
     .boxed1 { 
margin: auto; 
padding: 2px; 
height: 750px; 
width: 700px; 
border: medium solid #000; 
font-size: 17px; 
    } 
.boxed2 { 
margin: auto; 
padding: 2px; 
height: auto; 
width: 500px; 
border: medium solid #000; 
font-size: 20px; 
} 
</style> 
<link href="fpdf.php" 
</head> 

<body> 

    <h1 align="center"> 
<style type="text/css"> 
    #NavBar nav .form #form1 .form tr td { 
color: #FFF; 
} 
</style> 

    <p align="center" class="boxed"><strong>EACAD003 – I1</strong></p> 
&nbsp; 

    <?php 
$grammar = $row_Recordset1['grammar']; 
$reading = $row_Recordset1["reading"]; 
    $writing = $row_Recordset1["writing"]; 
$listening = $row_Recordset1["listening"]; 
    $speaking = $row_Recordset1["speaking"]; 
    $assesment = $row_Recordset1["assesment"]; 

    ?> 

    <?php 
    $_SESSION["grammar"] = $_POST["grammar"]; 
    $_SESSION["reading"] = $_POST["reading"]; 
    $_SESSION["writing"] = $_POST["writing"]; 
    $_SESSION["listening"] = $_POST["listening"]; 
    $_SESSION["speaking"] = $_POST["speaking"]; 
    $_SESSION["assessment"] = $_POST["assessment"]; 

    if ($_SERVER['REQUEST_METHOD'] == 'POST') 
    { 
    $grammar = $_POST['Grammar']; 
    $reading = $_POST['Reading']; 
    $writing = $_POST['Writing']; 
    $listening = $_POST['Listening']; 
    $speaking= $_POST['Speaking']; 
    $assessment= $_POST['assessment']; 
     } 

    $Results = $grammar + $reading + $writing + $listening + $speaking +  $assessment; 
    $Overall = $Results/100; 
    $checkBox = implode(',', $_POST['Progress']); 


    if(isset($_POST['SubmitForm'])) 
    { 
    $query="INSERT INTO test_results (Grammar, Reading, Writing, Listening, Speaking, Assesment, Progress) VALUES ('$Grammar','$Reading','$Writing','$Listening','$Speaking','$assessment','" . $checkBox . "')"; 


    ?> 
    <form action="<?php echo $editFormAction; ?>" method="post" name="TestResults" class="boxed1" id="TestResults"> 
    <p>&nbsp;</p> 
    <div class="boxed2"> 
    <h3 align="center">ELIT LANGUAGE CENTRE </h3> 
    <h3 align="center">TEST RESULTS </h3> 
    <p align="center"> 
    <select name="ClassLevel" id="ClassLevel"> 
    <option value="Elementary 1" <?php if (!(strcmp("Elementary 1", $row_Recordset1['ClassLevel']))) {echo "selected=\"selected\"";} ?>>Elementary 1</option> 
    <option value="Elementary 2" <?php if (!(strcmp("Elementary 2", $row_Recordset1['ClassLevel']))) {echo "selected=\"selected\"";} ?>>Elementary 2</option> 
    <option value="Elementary 3" <?php if (!(strcmp("Elementary 3", $row_Recordset1['ClassLevel']))) {echo "selected=\"selected\"";} ?>>Elementary 3</option> 
    <option value="Intermediate 1" <?php if (!(strcmp("Intermediate 1", $row_Recordset1['ClassLevel']))) {echo "selected=\"selected\"";} ?>>Intermediate 1</option> 
    <option value="Intermediate 2" <?php if (!(strcmp("Intermediate 2", $row_Recordset1['ClassLevel']))) {echo "selected=\"selected\"";} ?>>Intermediate 2</option> 
    <option value="Intermediate 3" <?php if (!(strcmp("Intermediate 3", $row_Recordset1['ClassLevel']))) {echo "selected=\"selected\"";} ?>>Intermediate 3</option> 
    <option value="Pre-Intermediate 1" <?php if (!(strcmp("Pre-Intermediate 1", $row_Recordset1['ClassLevel']))) {echo "selected=\"selected\"";} ?>>Pre-Intermediate 1</option> 
    <option value="Pre-Intermediate 2" <?php if (!(strcmp("Pre-Intermediate 2", $row_Recordset1['ClassLevel']))) {echo "selected=\"selected\"";} ?>>Pre-Intermediate 2</option> 
    <option value="Pre-Intermediate 3" <?php if (!(strcmp("Pre-Intermediate 3", $row_Recordset1['ClassLevel']))) {echo "selected=\"selected\"";} ?>>Pre-Intermediate 3</option> 


    <option value="<?php echo $row_Recordset1['ClassLevel']?>"<?php if (!(strcmp($row_Recordset1['ClassLevel'], $row_Recordset1['ClassLevel']))) {echo "selected=\"selected\"";} ?>><?php echo $row_Recordset1['ClassLevel']?></option> 
     <?php 
      }  while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); 
    $rows = mysql_num_rows($Recordset1); 
    if($rows > 0) { 
    mysql_data_seek($Recordset1, 0); 
    $row_Recordset1 = mysql_fetch_assoc($Recordset1); 
     } 
    ?> 
     </select> 
     </p> 
    </div> 
     <table width="632" border="0" align="center"> 
     <tr> 
    <td width="163">First Name</td> 
    <td width="260"><label for="Fname"></label> 
    <input name="Fname" type="text" id="Fname" /></td> 
    <td width="195"><label for="Lname"></label></td> 
</tr> 
    <tr> 
    <td>Last Name</td> 
    <td><label for="gt"></label> 
     <input name="Lname" type="text" id="Lname" /></td> 
    <td>&nbsp;</td> 
    </tr> 
    <tr> 
    <td>Passport No.</td> 
    <td><label for="date"> 
     <input name="gt" type="text" id="gt" /> 
    </label></td> 
    <td>&nbsp;</td> 
    </tr> 
    <tr> 
    <td>Date:</td> 
    <td><label for="teacher_name"> 
     <input type="text" name="date" id="date" /> 
    </label></td> 
    <td>&nbsp;</td> 
    </tr> 
    <tr> 
    <td>Teacher:</td> 
    <td><input type="text" name="teacher_name" id="teacher_name" /></td> 
    <td>&nbsp;</td> 
    </tr> 
    <tr> 
    <td>&nbsp;</td> 
    <td><label for="grammar"></label></td> 
    <td>&nbsp;</td> 
    </tr> 
    <tr> 
    <td>Grammar:</td> 
    <td><label for="grammar"></label> 
     <input name="grammar" type="text" id="grammar" />   <strong>/35</strong></td> 
    <td>&nbsp;</td> 
    </tr> 
    <tr> 
    <td>Reading:</td> 
    <td><label for="reading"></label> 
     <input name="reading" type="text" id="reading" /> 
     <strong>/20</strong></td> 
    <td>&nbsp;</td> 
    </tr> 
    <tr> 
    <td>Writing</td> 
    <td><label for="writing"> 
     <input name="writing" type="text" id="writing" /> 
    <strong>/20</strong></label></td> 
    <td>&nbsp;</td> 
    </tr> 
    <tr> 
    <td>Listening:</td> 
    <td><label for="listening"></label> 
     <input name="listening" type="text" id="listening" /> 
     <strong>/20</strong></td> 
    <td>&nbsp;</td> 
    </tr> 
    <tr> 
    <td>Speaking</td> 
    <td><input name="speaking" type="text" id="speaking" /> 
    <strong>/20</strong></td> 
    <td>&nbsp;</td> 
    </tr> 
    <tr> 
    <td>Teacher's Assesment:</td> 
    <td><label for="assesment"></label> 
    <input type="text" name="assesment" id="assesment" /> 
    <strong>/15</strong></td> 
    <td>&nbsp;</td> 
    </tr> 
    <tr> 
    <td>&nbsp;</td> 
    <td>&nbsp;</td> 
    <td><label for="textfield2"></label></td> 
    </tr> 
    <tr> 

    <td>&nbsp;</td> 
    <td><p> 
     <input name="overall" type="text" id="overall" value="<?php echo "$result" ?>"/> 
     <label for="overall"></label> 
     /130</p></td> 
    <td><p> 
     <input name="percentage" type="text" id="percentage" value="<?php echo "$Overall" ?>" /> 
    %</p></td> 
    </tr> 
    <tr> 

    <td>&nbsp;</td> 
    <td><input type="button" name="Calculate" id="Calculate" value="Calculate" /></td> 

    <td>&nbsp;</td> 
     </tr> 
     <tr> 
     <td>Teacher's Recommendation:</td> 
    <td>Repeat 

     </tr> 
     <tr> 
    <td>&nbsp;</td> 
    <td>&nbsp;</td> 
    <td>&nbsp;</td> 
    </tr> 
    <tr> 
    <td>&nbsp;</td> 
    <td>&nbsp;</td> 
    <td>&nbsp;</td> 
    </tr> 
    </table> 
    <input type="hidden" name="MM_insert" value="TestResults" /> 

     </form> 
    <form id="form1" name="form1" method="submit" action=""> 
    <label for="ClassLevel"></label> 
    <input type="submit" name="SubmitForm " id="SubmitForm " value="Submit Grades" /> 
    <br /> 
    <p> 
    </p> 
    </body> 
    </html> 
     </td> 
     </form> 


    <?php 
    mysql_free_result($Recordset1); 

    mysql_free_result($Recordset2); 

    ?> 
+0

여기에 오류를 게시 할 수도 있습니까? – sheetal

+0

'132-134' 줄을 제거하십시오 ...'$ row_Recordset1'도'$ _POST'와 어떻게 같은가요? –

+0

오류 메시지 –

답변

0

내 문제 선 152 \ xamppnew \ htdocs를 \ loginSignup \ teachersPage.php 비 존재 변수를 사용한다.

예 : 라인 135-140

$ _POST 벨으로 초기 => 정의되지 않은 오류

수정 코드에 존재하지 않습니다 : 이 있는지 확인 변수 이전 값으로 설정할 기존

$_SESSION["grammar"] = isset($_POST["grammar"]) ? $_POST["grammar"] : ''; 

http://php.net/manual/en/function.isset.php

희망 하시길 바랍니다.

+0

내 모든 변수가 정의되었습니다. 감사합니다! –

관련 문제