gpt4 book ai didi

php - 如何解决未定义索引的问题

转载 作者:行者123 更新时间:2023-11-29 08:48:25 26 4
gpt4 key购买 nike

我的数据库中有一个错误..据说代码中从第41行到第50行有 undefined index ..在我的网站中,我尝试将表单中的数据插入到PhpMyAdmin数据库中,一切正常除了这个...

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

数据库.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

>

最佳答案

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

关于php - 如何解决未定义索引的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11941716/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com