Jump to content


Traveller

Member Since 06 Aug 2016
Offline Last Active Aug 09 2016 10:09 AM
-----

Topics I've Started

GroceryCrud Add and Update does not work

06 August 2016 - 12:32 PM

Hi,

 

I´m new to grocerycrud. I set up according the instructions to display /test/employees. The databse will be displayed, I can delete entries, but this is not working:

 - I can´t add records: "An error has occured on insert" popup appears.

 - I cant edit a record. Klickin on "update changes" results in "An error has occurred on saving" and "Loading, updating changes is loading forever.

 - (there is no refresh of the result list after deleting an item. manually refresh the site shows the entry is deleted).

 

To secure up a little bit, I changed the directories. The webroot is /public_html. so I have:

 

assets: /public_html/ci/assets

application: /app

system: /sys

 

and therefore set in index.php:

        $system_path = '../../sys';
        $application_folder = '../../app';
        $view_folder = '';

 

the database.php (logindetails working):$active_group = 'default';
$query_builder = TRUE;

$db['default'] = array(
        'dsn'   => '',
        'hostname' => 'localhost',
        'username' => 'MYUSERNAME',
        'password' => 'MYSQLPW',
        'database' => 'MYDATABASENAME',
        'dbdriver' => 'mysql',
        'dbprefix' => '',
        'pconnect' => FALSE,
        'db_debug' => (ENVIRONMENT !== 'production'),
        'cache_on' => FALSE,
        'cachedir' => '',
        'char_set' => 'utf8',
        'dbcollat' => 'utf8_general_ci',
        'swap_pre' => '',
        'encrypt' => FALSE,
        'compress' => FALSE,
        'stricton' => FALSE,
        'failover' => array(),
        'save_queries' => TRUE
);

 

*** Controller app/controlers/gipdb/Test.php ***

 

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Test extends CI_Controller {

function __construct()
{
        parent::__construct();

//* CodeIgniter Standard Libraries *
$this->load->database();
$this->load->helper('url');
//* ------------------------------ *

$this->load->library('grocery_CRUD');
}

public function index()
{
echo "<h1>Welcome to this world </h1>";
die();
}

public function employees()
{
$this->grocery_crud->set_table('employees');
$output = $this->grocery_crud->render();

$this->_example_output($output);
}

function _example_output($output = null)

{
$this->load->view('gipdb/test_template.php',$output);
}

}

?>

 

*** The Template code (app/views/dipdb/test_template.php) is as in the grocerycrud introduction ***

 

<!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>
<!-- Beginning header -->
    <div>
        <a href='<?php echo site_url('examples/offices_management')?>'>Offices</a> |
        <a href='<?php echo site_url('examples/employees_management')?>'>Employees</a> |
        <a href='<?php echo site_url('examples/customers_management')?>'>Customers</a> |
        <a href='<?php echo site_url('examples/orders_management')?>'>Orders</a> |
        <a href='<?php echo site_url('examples/products_management')?>'>Products</a> |
        <a href='<?php echo site_url('examples/film_management')?>'>Films</a>

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

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

************************************************************

So why does the insert/update does not work but the delete and read does work?

 

Trying the update from the sql console does work with the username in the table...

 

Can anyone help?

 

happy coding!