douque8861 2019-01-23 02:28
浏览 21

当我删除或上传文件时,为什么我在$ _GET方法中收到未定义的索引通知? [重复]

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>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求帮我调试一下freefem代码
    • ¥15 R语言Rstudio突然无法启动
    • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
    • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图