代码点火器返回空白页


Code Igniter Returning Blank Page

我使用的是Code Igniter 3.0。我的代码运行正常,但当我插入查询代码时,它突然返回空白页。当我运行inspect元素时,它显示错误500GET方法。这是我的控制器:

<?php
class main extends CI_Controller{    
    function index(){       
        $this->load->view('testjs2');}}

以下是视图:

<html>
<head>
<title>Testjs</title>
<!-- Bootstrap Core CSS -->
<link href="<?php echo base_url('css/bootstrap.min.css'); ?>" rel="stylesheet">
<!-- Custom CSS -->
<link href="<?php echo base_url('css/half-slider.css');?>" rel="stylesheet">
<link href="<?php echo base_url('css/sb-admin.css');?>" rel="stylesheet">
</head>
<body>
test
<div class="container">
<table class="table table-striped" id="dataTables-example2">
        <thead>
            <tr class="info">
            <th >no matrik</th>
            <th>Nama</th>
            <th >Email</style></th>                
            </tr>
        </thead>
        <?php  
        echo 'testlagi';    
        //$this->load->database();        
        $query = $this->db->query('SELECT * FROM wifiview_stsdaftar'); 
        foreach($query->result() as $row)
        {
            //$j= $row->NOMATRIK;
            ?>
            <tr>  
            <td><?php echo $row->NOMATRIK;?></td>          
            <td><?php echo $row->NAMA;?></a></td>
            <td><?php echo $row->EMAIL;?></td>                              
            </tr>                               
            <?php
        } ?>  
    <table> 
</div> <!-- end of div container -->

我完全不知道自己做错了什么。

请参阅命名约定

class main extends CI_Controller{  
      ^// m should be capital letter
class Main extends CI_Controller{ 

类名应该以大写字母开头,controllersmodelslibraries的文件名也是如此。

有关更多信息(特别是File NamingClass and Method Naming),请参阅代码点火器3样式指南

你好,我相信你忘记加载模型了。这是一个常见的错误。

$this->load->model('model_name');

请试用