This question already has an answer here:
While I was building a dynamic menu, I encountered notice when I run my code. I've tried everything but nothing solve my problem.
<?php
include_once 'includes/dbh.inc.php';
$lessonID = $_GET['lessonID']; <!--this is the line 52-->
$sql = "SELECT * FROM gallery WHERE lessonID = '$lessonID'";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
echo "SQL statement failed!";
} else {
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
while ($row = mysqli_fetch_assoc($result)) {
switch ($lessonID) {
case 1:
echo'<div class="img-container">
<a href="#" class="video">
<video width="200" controls="true" poster="" id="video">
<source src="img/gallery/'.$row["imgFullNameGallery"].'" type="video/mp4">
Your browser does not support HTML5 video.
</video>
<h3>'.$row["titleGallery"].'</h3>
<p>'.$row["descGallery"].'</p>
</a>
<!--My delete function--><a href="delete_L1.php?op=delete&filename='.$row["imgFullNameGallery"].'">Delete</a>
<div id="status" class="incomplete">
<span>Status: </span>
<span class="status complete">COMPLETE</span>
<span class="status incomplete">INCOMPLETE</span>
<br />
</div>
<div>
<span id="played">0</span> seconds out of
<span id="duration"></span> seconds.
</div>
</div>';
break;
In my code, I have a menu in home.php
that the user will be directed to lesson1.1.php
where the user can watch a video. I use GET
method in my lesson1.1.php
to get the value of my link's ID from my home.php
so that I can display a video according to the id the method GET
in home.php
. Everything is good but when I delete or upload a new video, I get a notice of:
Notice : Undefined index: lessonID in C:\xampp\htdocs\project2\admin\lesson1.1.php on line 52
Line 52 is where I used GET method.
Sorry for my English, I hope you understand my question.
PS. I have declared my index in the home.php
. I only get notice message when I delete file.
This is where I get the lessonID:
<li><a href="lesson1.1.php?lessonID=<?php echo $lesson['lessonID'];?>"><?php echo $lesson['lessonName']; ?></a></li>
UPDATE
I tried using isset in my switch statement but still get the same notice.
</div>