0

I've got an existing project in code igniter and wanted to start using grocery crud with it. I'm running it on a recent install of wamp, php 5.4, apache 2.4.4.

I followed the basic set up, copy and pasting the files over to my code igniter directory and I set up a controller to display a table with crud functionality as in the tutorial, but I get the following error when viewing it:

Fatal error: Uncaught exception 'Exception' with message 'On the state "update" you must have post data' in C:\wamp\www...\application\libraries\Grocery_CRUD.php on line 3185

Controller:

<?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);    
    }
}

View as referenced in controller:

<!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>

I've changed around my base url as I'd seen this may be the issue with somewhat similar errors. This had no effect. I do have mod_rewrite enabled in apache and .htaccess to get rid of index.php in the url - could this be an issue?

I've been looking at the file which causes the error (Grocery_CRUD.php) and it happens when I call the render() method, which calls a method getStateInfo() which calls another method that sets the state to 6 or 'update', this then checks if the $_POST variable is empty in getStateInfo() which I'm guessing it is because it throws the error. Why any of the aforementioned happens I'm unsure but was just my findings so far in trying to understand what exactly is going on. If you need any info please ask.

.htaccess file:

<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>
haakym
  • 12,050
  • 12
  • 70
  • 98
  • check this forum: http://www.grocerycrud.com/forums/topic/104-exception-raise/ – Kumar V Feb 21 '14 at 12:09
  • Thanks, I already looked at thread and it didn't solve my problem. Though I didn't understand the RewriteCond in the .htaccess file in the final post. Do I need to add all my folders in there? When I did it directed me to the wamp startup page. Also, I've tried signing up to the grocerycrud forum to ask my question, but the account activation email has yet to be delivered to my email address, hence why I'm posting here. And yes I've checked my spam folder and resent the activation. – haakym Feb 21 '14 at 13:28
  • 1
    I'm not good in htaccess. So just post your htaccess code and your url details. And also, add htaccess tag. – Kumar V Feb 21 '14 at 13:55
  • Hello @haakym , did you tried without the .htaccess file to see if it will work for you? – John Skoumbourdis Feb 24 '14 at 22:57
  • Hi @JohnSkoumbourdis thanks for your reply. I just gave that a try i.e. taking the file out of the project completely and appending index.php after my project path, but it's producing the same error. The only difference was that previously when I was using the .htaccess file I needed to write the controller with a capital letter firstly, this time I didn't need to do that. I think I may try grocery crud on a clean install of code igniter, link it up to my db and see if that makes a difference. Also, do you have any idea why I didn't get my account activation for the grocery crud forums? Thanks – haakym Feb 25 '14 at 08:49
  • Hello @haakym , yes try a fresh install and see :) . As for the forums, please check your spam folder. If there is still a problem, please send me a personal email with your username so I can activate your account. You can find my email address at: http://www.web-and-development.com/skoumbourdis/ – John Skoumbourdis Feb 25 '14 at 09:21
  • @haakym Managed to solve? – Tiago Ferezin Jul 24 '19 at 19:45
  • @TiagoFerezin - sorry I gave up on this as I couldn't get it working perhaps John can help? – haakym Jul 25 '19 at 14:51

1 Answers1

0

I had the same problem . This is how I solved it: I removed the select boostrap libraries(the js files) that interfiered with the grocery crud libraries...

Andreea Onica
  • 315
  • 5
  • 13