微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

注意:尝试在第97行的C:\ xampp \ htdocs \ res \ index.php中访问类型为null的值的数组偏移量名称:

如何解决注意:尝试在第97行的C:\ xampp \ htdocs \ res \ index.php中访问类型为null的值的数组偏移量名称:

我已经创建了学生成绩门户。如果卷数和出生日期与数据库中的数据匹配,则必须显示学生的姓名和标记。成功地,它将显示学生的标记详细信息。但是在显示学生姓名时显示错误。下面是错误。我现在要做什么?

注意:尝试在第97行的C:\ xampp \ htdocs \ res \ index.PHP中访问类型为null的值的数组偏移量

名称

PHP

<?PHP
 include('header.PHP')
  ?>
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-12 jumbotron">
                        <h2 style="text-align: center;">                                
Sri Meenakshi Government College for Women                                 
                        </h2>                            
                </div>
            </div>
        </div>

        <div class="student-info text-center">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-md-12 jumbotron">
                        
                        <form action="index.PHP" method="post">
                        <input type="text" name="sname" placeholder="Your Full Name" style="width: 240px;height: 35px;">
            <input type="text" name="roll" placeholder="Your Register Number" style="width: 240px;height: 35px;">
            <input type="text" name="birth" placeholder="mm/dd/yyyy" style="width: 240px;height: 35px;">
              <input type="submit" name="show" value="Show Result" class="btn btn-success text-center" style="margin-left: -100px;" >  
              <center><button onclick="window.print()" class="btn">Save</button>
                        <style>
                        .btn{
                            width:250px;
                            float:right;
                        }
                        </style>
                        </form>                            
                    </div>
                </div>
            </div>
        </div>
<table class="table table-striped table-bordered table-responsive text-center">
<tr >
    <th class="text-center">Subject</th>
    <th class="text-center">Internal Mark</th>
    <th class="text-center">External Mark</th>
    <th class="text-center">Total</th>
    <th class="text-center">Result</th>
</tr>
<?PHP 
include('dbcon.PHP');
if (isset($_POST['show'])) {
                        //echo "<center>"."Name:" .$_POST['sname']."<br>";
                        //echo "Register Number:" .$_POST['roll']."<br>";                        
                        $dateofbirth = $_POST['birth'];
                        $RollNo = $_POST['roll'];
                        $sql = "SELECT * FROM `student` WHERE `birth` = '$dateofbirth' AND `rollno`='$RollNo'";
    $result = MysqLi_query($conn,$sql);
    if (MysqLi_num_rows($result)>0) {
        while ($DaTarows = MysqLi_fetch_assoc($result)) {
            $Id = $DaTarows['id'];
            $RollNo = $DaTarows['rollno'];
            $Name = $DaTarows['name'];
            $sub = $DaTarows['subject'];
            $intm = $DaTarows['intmark'];
            $extmark = $DaTarows['extmark'];
            $tot = $DaTarows['total'];
            $res = $DaTarows['result'];
            ?>
            <tr>
                <td><?PHP echo $sub; ?></td>
                <td><?PHP echo $intm; ?></td>
                <td><?PHP echo $extmark; ?></td>
                <td><?PHP echo $tot; ?></td>
                <td><?PHP echo $res; ?></td>
            </tr>
            <?PHP
        }
        
    } else {
        echo "<tr><td colspan ='7' class='text-center'>No Record Found</td></tr>";
    }
   echo "name:".$DaTarows['name']."<br>";
 }
 ?>

here is my database entries

请帮助我解决这个问题。

解决方法

这是因为if语句没有通过,name里面没有任何值,所以它抵消了NULL

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。