⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Can't update row, but I can delete it



dallen33
  • profile picture
  • Member

Posted 31 May 2012 - 15:52 PM

When I go to:

http://localhost:8888/directory/examples/photos

I can view the photos table. I can delete a row. But when I go into Edit, and click Update Changes, the "Loading, updating changes..." message shows and stays. In my Safari console, the following error is displayed:

POST [color="#545454"]http://localhost:[/color][color="#545454"]8888[/color][color="#545454"]/directory/examples/photos/update_validation/84[/color] 500 (Internal Server Error)

Here is the function in examples.php:


function photos()
{
try{
/* This is only for the autocompletion */
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('photos');
$crud->set_subject('Photos');
$crud->columns('token', 'name');

$output = $crud->render();

$this->_example_output($output);

}catch(Exception $e){
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
}


Any idea why?

archer8
  • profile picture
  • Member

Posted 12 June 2012 - 14:30 PM

I don't have an answer for you, but I am encountering the same problem...

I'm using a session to verify the user is logged in, I've noticed it works fine when I remove it from my login system.

dallen33
  • profile picture
  • Member

Posted 12 June 2012 - 14:53 PM

I would love to get an answer to this. I love GroceryCRUD, but in this instance, I can't seem to use it.

noskov.biz
  • profile picture
  • Member

Posted 12 June 2012 - 16:03 PM

Hi there!

Please, tell me what versions of codeigniter & grocery_crud do you use? And what response have got in firebug? Is there any errors?

If in your config.php file $config['csrf_protection'] = TRUE, try to change it to FALSE.

Celso Soares
  • profile picture
  • Member

Posted 09 May 2013 - 13:03 PM

Same problem here! i can't add new items neither update them.
in firefox i see that message in console:
"NetworkError: 500 Internal Server Error - http://localhost:6915/examples/clients_management/update_validation/1"

 

i have $config['csrf_protection'] = FALSE, so i think that the problem is not here. I have the codeigniter(v2.1.3) and grocerycrud(v1.3.3) last versions.


davidoster
  • profile picture
  • Member

Posted 09 May 2013 - 13:22 PM

Probably it has to do with the fact that you're haveing your apache on an other port than the default 80?

I wouldn't know, but I suspect that it has to do with apache's configuration. So you need to check apache's error log first.


Celso Soares
  • profile picture
  • Member

Posted 09 May 2013 - 15:46 PM

i found a weird solution
 
delete line like this one if you are using required restrictions:

 

$crud->required_fields('name');
 

 

 
now the update and create works fine!
 
my code was:

 

$crud = new grocery_CRUD();


$crud->set_theme('datatables');
$crud->set_table('projects');
$crud->set_subject('Project');
$crud->required_fields('name');
$crud->columns('name','image','description');
            
$crud->set_field_upload('image','assets/img/projects');
            
$output = $crud->render();
            
$this->_admin_output($output);
 

 


Celso Soares
  • profile picture
  • Member

Posted 09 May 2013 - 15:53 PM

Probably it has to do with the fact that you're haveing your apache on an other port than the default 80?

I wouldn't know, but I suspect that it has to do with apache's configuration. So you need to check apache's error log first.


davidoster
  • profile picture
  • Member

Posted 09 May 2013 - 19:49 PM

Well, required_fields uses CI's validaton rules.

So we need to investigate what happens exactly when this happens.

 

Try to follow this post to enable the logs and see what happens.


HenryJahja
  • profile picture
  • Member

Posted 15 June 2013 - 22:54 PM

i've facing this problem just a moment ago.

i can add, and delete but i cant update the record.

so i'm checking and finding that my primary key went wrong

i add new primary/index key to the table just to make sure the grocerycrud functions edit the right record (row).

 

before, was i just make a key that prohibit two record to have exact same 2 field

username,transaction_id
abc,001
abc,002 

but now i change the structure table to have another index key

exchange_id,username,transaction_id
01,abc,001
02,abc,002
03,cba,001
04,cba,002

i think it because the grocerycrud need an exact primary key field to ensure which record (row) is being edited.

 

hope it helps


goFrendiAsgard
  • profile picture
  • Member

Posted 16 June 2013 - 00:02 AM

Exactly, that is the case. groceryCRUD need an integer auto increment primary key.

It is a good practice to always have such a primary key.

Supose you have a student table which logically should have student_registration_id to be primary key.
Adding another integer auto increment primary key will enable you to edit student_registration_id without modifying all related foreign key.

Yes, I know that student registration id should not be changed. But some people (usually the boss) doesn't think so  :rolleyes:


HenryJahja
  • profile picture
  • Member

Posted 16 June 2013 - 02:01 AM

Exactly, that is the case. groceryCRUD need an integer auto increment primary key.

It is a good practice to always have such a primary key.

Supose you have a student table which logically should have student_registration_id to be primary key.
Adding another integer auto increment primary key will enable you to edit student_registration_id without modifying all related foreign key.

Yes, I know that student registration id should not be changed. But some people (usually the boss) doesn't think so  :rolleyes:

 

I really cant explain my thoughts better, as english isn't my mother language, lol.

That's what i really meant.

Thanks!  :lol: