⚠ 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

Internal Server Error (500)



tapan.thapa
  • profile picture
  • Member

Posted 06 November 2014 - 08:25 AM

Hello GC Team,

 

I am new user of GC and started working on it since yesterday only.

 

I am facing Internal Server Error (500) issue while adding/mapping new entry.

 

I have three tables.

 

1. operators (Fields: id,operator_name)

2. circles (Fields: id,circle_name)

3. operators_circles (This is mapping table. One operator may belongs to multiple circles) (Fields: id,operator_id,circle_id,priority)

 

CI Methods:

public function operator - working fine

public function circle - working fine

public function operator_circle - not working fine (It is a mapping method. Single operator may belongs to multiple circles.)

 

Method definition of operator_circle:

 

public function operator_circle() {

        $crud = new grocery_CRUD();

        $crud->set_table('operators');
        $crud->set_relation('id', 'operators', 'operator_name');
        $crud->set_relation_n_n('circle_name', 'operators_circles', 'circles', 'operator_id', 'circle_id', 'circle_name', 'priority');
        
        $crud->set_subject('Operator-Circle Mapping');
        $crud->display_as('id', 'Operator Name');
        $crud->display_as('operator_name', 'Operator Name');
        $crud->display_as('circle_name', 'Circle Name');
        $crud->fields('id', 'circle_name');
        $crud->columns('operator_name', 'circle_name');

        $output = $crud->render();

        $this->_load_view($output);
    }

 

Just a note: Edit is working perfectly fine. That means i can click on edit button and can map operator with circle perfectly fine.

 

Only while adding/mapping new entry, it is not working and throwing internal server error 500 on firebug.

 

Can you guys please suggest if i am doing any mistake here?

 

Many Thanks in advance.

 

 


Amit Shah
  • profile picture
  • Member

Posted 06 November 2014 - 13:10 PM

Hi there,,

 

i believe the issue is all in here

$crud->set_relation_n_n('circle_name', 'operators_circles', 'circles', 'operator_id', 'circle_id', 'circle_name', 'priority');

 

you dont have circie_name as the field in the operators_circles table. It should be circle_id there and not the circle_name

you can refer back to the documentation and re-frame the same.


tapan.thapa
  • profile picture
  • Member

Posted 06 November 2014 - 14:11 PM

Hi Amit,

 

Many thanks for your reply.

 

I saw that you are the most active user on this forum as you have almost provided your help on all threads.

 

I am just pulling my hairs to understand the n to n concept.

 

I have tried below code but no luck. List, View and Edit works fine. I don't know why add is not working.

 

public function operator_circle() {

        $crud = new grocery_CRUD();
        $crud->set_table('operators');
        $crud->set_relation('id', 'operators', 'operator_name');
        $crud->set_relation_n_n('circles', 'operators_circles', 'circles', 'operator_id', 'circle_id', 'circle_name', 'priority');

        $crud->set_subject('Operator-Circle Mapping');
        $crud->display_as('id', 'Operator Name');
        $crud->display_as('operator_name', 'Operator Name');
        $crud->display_as('circles', 'Circle Name');
        $crud->fields('id', 'circles');
        $crud->columns('operator_name', 'circles');
        //$crud->set_rules('operator_name', 'Operator Name', 'required|is_unique[operators.operator_name]');

        $output = $crud->render();
        $this->_load_view($output);
    }

 

Can you please provide some code example for the line which you have suggested?

 

Will it be like below? No luck with below as well

 

$crud->set_relation_n_n('circles', 'operators_circles', 'circles', 'circle_id', 'id', 'circle_name', 'priority');

 


Amit Shah
  • profile picture
  • Member

Posted 06 November 2014 - 16:15 PM

Hi there - i will recommend you turn on the CI mode into Development from Production and you might be able to see the issue...

Secondly .. also look @configuring the php info to throw out error on screen.

Well in this case you can refer to the error log for it might have registered the issue / error for the same.