Code Igniter& Grocery Crud错误 - 关于状态"更新"你必须有发布数据

时间:2014-02-21 12:01:37

标签: php .htaccess codeigniter grocery-crud

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

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

  

致命错误:未捕获的异常'Exception',消息'On the state   “更新”你必须拥有发布数据   第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或'更新',然后检查$_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 :(得分:0)

我遇到了同样的问题。这就是我解决这个问题的方法:我删除了与杂货店文件库混合的精选boostrap库(js文件)......