みんな元気だといいのですが:)
実際、未定義の変数の複数のエラーが発生していますが、コードは完全に問題ないようです。スクリプトでこの問題が何度も発生し、本当にうんざりしています。それは私の仕事を遅らせます。
コードを確認し、解決策を送信してください。どんな種類の助けもいただければ幸いです。前もって感謝します
これがmanage-learning-material.phpの私のコードです
<?php include("../includes/config.php"); ?>
<?php
if ($_SESSION["isteacher"])
{
$con=mysql_connect($dbserver,$dbusername,$dbpassword);
if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db($dbname, $con);
$courseid=$_GET["id"];
$result = mysql_query("SELECT * FROM courses WHERE (id='".$courseid."')");
while($row = mysql_fetch_array($result))
{
$id=$row['id'];
$title = $row['title'];
$des = $row['description'];
$subjectid = $row['subjectsid'];
}
mysql_close($con);
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Manage Learning Material</title>
</head>
<body>
<h2 class="alt">COURSE VIEW </h2>
<?php
if (isset($_GET["status"]))
{
if($_GET["status"]==1)
{
?>
<div class="success">
<?php
echo("<strong>Material has been added in Course Successfully!</strong>");
?>
</div>
<?php
}
if($_GET["status"]==2)
{
?>
<div class="success">
<?php
echo("<strong>Learning Material has been Edited Successfully!</strong>");
?>
</div>
<?php
}
}
?>
<form id="form" method="post" action="manage-learning-material-action.php">
<input type="hidden" value="<?php echo $courseid; ?>" name="id" />
<label>Course Name:</label><input type="text" name="title" id="title" class="text" value="<?php echo $title; ?>" /><br /><br />
<label>Choose Subject:</label>
<?php
$con=mysql_connect($dbserver,$dbusername,$dbpassword);
if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db($dbname, $con);
$result = mysql_query("SELECT * FROM subjects");
echo "<select name='subjectsid'>\n";
while($row = mysql_fetch_array($result))
{
echo "<option value='".$row['id'] . "'";
if ($subjectid==$row['id'])
echo 'selected="selected"';
echo " >" . $row['subjectname'] . "</option>\n";
}
echo "</select>\n";
mysql_close($con);
?>
<br /><br />
<label>Description:</label><br /><textarea name="description" id="description"><?php echo $des; ? ></textarea><br /> <br />
</form>
</div>
</div>
<?php include("../includes/footer.php"); ?>
</div>
</body>
</html>
<?php
}
else
{
header("Location: ".$fullpath."login/unauthorized.php");
}
?>
manage-learning-material-action.php
<?php include("../includes/config.php");?>
<?php
$id=$_POST["id"];
$title=$_POST["title"];
$des=$_POST["description"];
$subjectid=$_POST["subjectsid"];
$con=mysql_connect($dbserver,$dbusername,$dbpassword);
if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db("ombts", $con);
$query=("UPDATE courses SET title='".$title."', description='".$des."', subjectsid='".$subjectid."' WHERE (id='".$id."')");
$result=mysql_query($query);
if($result){
echo header("Location:manage-courses.php?status=2");
}
mysql_close($con);
?>
エラー/警告は次のとおりです。
Notice: Undefined index: id in C:\xampp\htdocs\project\teacher\manage-learning-material.php on line 11
<br /><b>Notice</b>: Undefined variable: title in <b>C:\xampp\htdocs\project\teacher\manage-learning-material.php</b> on line <b>86</b><br />
<b>Notice</b>: Undefined variable: subjectid in <b>C:\xampp\htdocs\project\teacher\manage- learning-material.php</b> on line <b>102</b><br />
>Literature7</option>
<option value='3'<br />
<b>Notice</b>: Undefined variable: subjectid in <b>C:\xampp\htdocs\project\teacher\manage-learning- material.php</b> on line <b>102</b><br />
>Management</option>
<option value='7'<br />
<b>Notice</b>: Undefined variable: subjectid in <b>C:\xampp\htdocs\project\teacher\manage-learning- material.php</b> on line <b>102</b><br />
>Marketing</option>
<option value='5'<br />
<b>Notice</b>: Undefined variable: subjectid in <b>C:\xampp\htdocs\project\teacher\manage-learning- material.php</b> on line <b>102</b><br />
>Science</option>
<option value='6'<br />
<b>Notice</b>: Undefined variable: subjectid in <b>C:\xampp\htdocs\project\teacher\manage-learning- material.php</b> on line <b>102</b><br />
>Science2</option>
<option value='4'<br />
<b>Notice</b>: Undefined variable: subjectid in <b>C:\xampp\htdocs\project\teacher\manage-learning- material.php</b> on line <b>102</b><br />
<b>Notice</b>: Undefined variable: des in <b>C:\xampp\htdocs\project\teacher\manage-learning- material.php</b> on line <b>110</b><br />