首页 文章

Code Igniter&Grocery Crud错误 - 在状态“更新”中,您必须拥有发布数据

提问于
浏览
0

我有一个代码点火器的现有项目,并希望开始使用杂货crud . 我在最近安装的wamp,php 5.4,apache 2.4.4上运行它 .

我按照基本设置,将文件复制并粘贴到我的代码igniter目录,然后设置一个控制器来显示一个带有crud功能的表,如教程中所示,但是在查看时出现以下错误:

致命错误:未捕获的异常'异常',消息'在状态'更新“你必须有帖子数据”在第3185行的C:\ wamp \ www ... \ application \ libraries \ Grocery_CRUD.php

控制器:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Previousqualification extends CI_Controller {
    function __construct(){
         parent::__construct();

        /* Standard Libraries of codeigniter are required */
        $this->load->database();
        $this->load->helper('url');
        /* ------------------ */ 
        $this->load->library('grocery_CRUD');
    }

    public function test(){
        $this->grocery_crud->set_table('previousqualification');
        $output = $this->grocery_crud->render();
        $this->_crud($output);        
    }

    function _crud($output = null){
        $this->load->view('view_previousqualification.php',$output);    
    }
}

在控制器中引用的视图:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />

<?php 
foreach($css_files as $file): ?>
    <link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />

<?php endforeach; ?>
<?php foreach($js_files as $file): ?>

    <script src="<?php echo $file; ?>"></script>
<?php endforeach; ?>

<style type='text/css'>
body
{
    font-family: Arial;
    font-size: 14px;
}
a {
    color: blue;
    text-decoration: none;
    font-size: 14px;
}
a:hover
{
    text-decoration: underline;
}
</style>
</head>
<body>

<!-- End of header-->
    <div style='height:20px;'></div>  
    <div>
        <?php echo $output; ?>

    </div>
<!-- Beginning footer -->
<div>Footer</div>
<!-- End of Footer -->
</body>
</html>

我已经改变了我的基本网址,因为我看到这可能是有些类似错误的问题 . 这没有效果 . 我确实在apache和.htaccess中启用了mod_rewrite来摆脱url中的index.php - 这可能是个问题吗?

我一直在查看导致错误的文件(Grocery_CRUD.php),当我调用 render() 方法时会发生这种情况,该方法调用方法 getStateInfo() 调用另一种方法将状态设置为6或'update',然后检查是否 $_POST 变量在 getStateInfo() 中是空的,我不确定,但到目前为止我只是试图了解究竟发生了什么 . 如果您需要任何信息,请询问 .

.htaccess文件:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /codeIgniter

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to acces a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

1 回答

  • 0

    我有同样的问题 . 这就是我解决它的方法:我删除了与杂货crud库交互的select boostrap库(js文件)......

相关问题