0

我的数据库中有一个错误。据说代码中的第 41 行到第 50 行有未定义的索引。在我的网站中,我尝试将表单中的数据插入到 PhpMyAdmin 数据库中,除此之外一切正常。 ..

错误是:注意:未定义索引:第 41 - 50 行 C:\xampp\htdocs\ers\Database.php 中的服务

数据库.php:

<html>
<body>
<?php
$con = mysql_connect("localhost","root","123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

// some code

?>


<table border="1">
    <tr >
        <td>Finding</td>
        <td>ServiceType</td>
        <td>Title</td>
        <td>RootCause</td>
        <td>RiskRating</td>
        <td>Impact</td>
        <td>Efforts</td>
        <td>Likelihood</td>
        <td>Finding</td>
        <td>Implication</td>
                <td>Recommendation</td>
                        <td>Report</td>
    </tr>


<?php





mysql_select_db ( "ers_1", $con);
$sql="INSERT INTO findings (ServiceType_ID, Title, RootCause_ID, RiskRating_ID, Impact_ID, Efforts_ID, Likelihood_ID, Finding,Implication,  Recommendation, Report_ID) VALUES (

    '$_POST[Services]',
    '$_POST[title]',
    '$_POST[RootCause]',
    '$_POST[RiskRating]',
    '$_POST[impact]',
    '$_POST[Efforts]',
    '$_POST[likelihood]',
    '$_POST[Finding]',
    '$_POST[Implication]',
    '$_POST[Recommendation]',
    '1'
    )";



$result = mysql_query("SELECT * FROM findings");

while($row = mysql_fetch_assoc($result)) 
  {
  echo "<tr>";
  echo "<td>" . $row['Finding_ID'] . "</td>";                                           
  echo "<td>" . $row['ServiceType_ID'] . "</td>";
  echo "<td>" . $row['Title'] . "</td>";
  echo "<td>" . $row['RootCause_ID'] . "</td>";
  echo "<td>" . $row['RiskRating_ID'] . "</td>";
  echo "<td>" . $row['Impact_ID'] . "</td>";
   echo "<td>" . $row['Efforts_ID'] . "</td>";
    echo "<td>" . $row['Likelihood_ID'] . "</td>";
    echo "<td>" . $row['Finding'] . "</td>";
    echo "<td>" . $row['Implication'] . "</td>";

    echo "<td>" . $row['Recommendation'] . "</td>";
    echo "<td>" . $row['Report_ID'] . "</td>";
  //echo "<td><a href='edit.php'>[EDIT]</a> <a href='delete_risk.php?risk_no=" . $row['risk_no'] . "'>[DELETE]</a></td>";
  echo "</tr>";
  }



mysql_close($con);
?> 

<input type="button" value="Back" onclick="window.location.href='option_Frame.php'" />

</body>
</html

>

4

2 回答 2

2

听起来 $_POST['Services'] 没有发布,而不是数据库问题。

于 2012-08-13T20:25:02.783 回答
0

检查您的 HTML;可能没有输入元素name="Services"

于 2012-08-13T20:26:54.607 回答