user1593177
user1593177

Reputation: 21

How can I solve the undefined index

I have a mistake in my database .. It is written that there is undefined index from line 41 until 50 in the code .. In my website I tried to insert data from a form to the PhpMyAdmin database and everything is working fine except this...

The error is : Notice: Undefined index: Services in C:\xampp\htdocs\ers\Database.php on line 41 - 50

Database.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

>

Upvotes: 0

Views: 1220

Answers (2)

Rogier Pennink
Rogier Pennink

Reputation: 418

Check your HTML; there is probably no input element with name="Services".

Upvotes: 0

Mike Brant
Mike Brant

Reputation: 71384

It sounds like $_POST['Services'] was not posted rather than this being a database issue.

Upvotes: 2

Related Questions