Jump to content


GroceryCrud Add and Update does not work

add update database insert

  • Please log in to reply
3 replies to this topic

#1 Traveller

Traveller

    Newbie

  • Members
  • Pip
  • 3 posts

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

 

 

 

 



#2 Traveller

Traveller

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 07 August 2016 - 01:37 PM

Nobody who can help?

some additional information: i´m using mariadb (mysql compatible) database and I tried with it the tables: MyISAM and InnoDB

If there is a solution to this decides if I will use grocerycrud or not ;(

 

Would be happy if someone could help!



#3 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

Posted 08 August 2016 - 06:10 AM

well.. changing the directories should not have impact like to add / update...

do 1 thing.. look up in the console .. look what error output it is giving in .. the code dose not have any issue as such .. just - look in the output in console for the error.



#4 Traveller

Traveller

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 08 August 2016 - 06:25 PM

good hint ;)  - Thank you I got it now.

 

Just for everone new to grocerycrud having the same problem (and for anyone interested especially grocery CRUD Master ;)

 

In the console I get the network error:

 

for the add: "NetworkError: 404 Not Found - http://MYDOMAIN.COM/...mployees/insert"
for the update: "NetworkError: 404 Not Found - http://MYDOMAIN.COM/...ees/update/1088"

the index.php is in http://MYDOMAIN.COM/ci/index.php so far the first part is correct. but then there is a second index.php

the edit screen is working on the url: http://MYDOMAIN.CON/...oyees/edit/1088

so I guess the correct path should be: http://MYDOMAIN.COM/...php/1102/insert

(just one /ci/index.php less).

 

THE PROBLEM: in the config.php I set

             $config['base_url'] = '/ci';

             $config['index_page'] = 'index.php';

 

and in the index.php:

             $system_path = '../../sys';

             $application_folder = '../../app';

homepage root pointed to was public_html/
test directory with index.php was public_html/ci/index.php

So if you wanna try to think yourself first, what´s wrong here, dont read after the *** stars ***

 

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

okay, here comes the solution:

.

.

.

.

.

             $config['base_url'] = '';

 

--> This was the soluton to not set a second 'index.php/ci'

 

Thank you so much for you help grocery CRUD Master.

 

best wishes from a Traveller ;)

 

 

 

 

 

 

 

 

 







Also tagged with one or more of these keywords: add, update, database, insert

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users