⚠ 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

Error Internal Server 500



nguyenthao
  • profile picture
  • Member

Posted 10 April 2015 - 15:43 PM

 <?php 

class User extends Admin_Controller{
public function __construct(){
parent::__construct();
// $this->load->library('grocery_CRUD');
// $this->load->model('grocery_CRUD_Model');
}
public function _example_output($output = null)
{
$this->load->view('user/show.blade.php',$output);
}
public function index(){
$this->_example_output((object)array('output' => '' , 'js_files' => array() , 'css_files' => array()));
}
public function users_management()
{
try{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('tbl_users');
$crud->set_subject('Users');
$crud->required_fields('id');
$crud->columns('id','email','password','fullname');
$crud->field_type('password', 'password');
$crud->callback_before_insert(function($post_array){
$post_array['password'] = md5($post_array['password'] );
return $post_array;
});
$crud->callback_before_update(function($post_array){
$post_array['password'] = md5($post_array['password'] );
return $post_array;
});
$output = $crud->render();
echo "dfsdfs";
$this->_example_output();
 
}catch(Exception $e){
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
}
function encrypt_password_callback($post_array) {
$post_array['password'] = md5($post_array['password']);
 
return $post_array;
}  
public function danhmucsanpham_management()
{
try{
$crud = new grocery_CRUD();
$crud->set_language("vietnamese");
$crud->set_theme('datatables');
$crud->set_table('tbl_danhmucsanpham')
->set_subject('Thông Tin Danh Mục Sản Phẩm')
->columns('ten_danhmuc','index');
$crud->display_as('Tên Danh Mục','Vị Trí')->display_as('Tên Danh Mục','Vị trí');
$output = $crud->render();
 
$this->_example_output($output);
 
}catch(Exception $e){
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
public function sanpham_management()
{
$query = "SELECT * FROM tbl_danhmucsanpham";
$data = $this->db->query($query)->result_array();
$id_danhmuc;
// print_r($data);
foreach($data as $value){
$k = $value["id"];
$id_danhmuc[$k] = $value["ten_danhmuc"];
}
// try{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('tbl_sanpham');
$crud->set_subject('Thông Tin Sản Phẩm');
$crud->required_fields('id');
$crud->columns('id','id_danhmuc','ten_sanpham','model_sanpham','gia_sanpham','info_sanpham','img_sanpham','alt_sanpham');
$crud->set_field_upload('img_sanpham','assets/uploads/sanpham');
$crud->field_type('id_danhmuc','dropdown',$id_danhmuc);
 
$output = $crud->render();
 
$this->_example_output($output);
 
// }catch(Exception $e){
// show_error($e->getMessage().' --- '.$e->getTraceAsString());
// }
}       
}
?>

 

11143265_926215324066533_922191218399011


nguyenthao
  • profile picture
  • Member

Posted 10 April 2015 - 15:43 PM

pls help me. Tks all so much


Amit Shah
  • profile picture
  • Member

Posted 12 April 2015 - 04:52 AM

$crud->callback_before_insert(function($post_array){
$post_array['password'] = md5($post_array['password'] );
return $post_array;
});
$crud->callback_before_update(function($post_array){
$post_array['password'] = md5($post_array['password'] );
return $post_array;
});

 

 

here is trouble

 

what GC library expects is either a s tring or arrayt and its neither of it

so create a function outside and set it the way it s expected to and it should solve