Welcome Guest, Not a member yet? Register   Sign In
Array to string conversion
#1

[eluser]Shiva666[/eluser]
I get this error
Quote:A PHP Error was encountered

Severity: Notice

Message: Array to string conversion

Filename: controllers/users.php

Line Number: 25

on that line is this code
Code:
$id || $rules['password'] .= '|required';

My users controller
Code:
public function edit($id = NULL){
  $id == NULL || $data['user'] = $this->mdl_users->get($id);
  $rules = $this->mdl_users->rules_admin;
  $id || $rules['password'] .= '|required';
  $this->form_validation->set_rules($rules);
  if($this->form_validation->run() == TRUE){
  
  }

  $data['view_file'] = "edit";
  $this->load->module('templates');
  $this->templates->admin($data);
  
}

public function _unique_email($str){
  $id = $this->uri->segment(4);
  $this->db->where('email', $this->input->post('email'));
  !$id || $this->db->where('id !=', $id);
  $user = $this->mdl_users->get();
  
  if(count($user)){
   $this->form_validation->set_message('_unique_email', '%s should be unique');
   return FALSE;
  }
  
  return TRUE;
}

my users model
Code:
class Mdl_users extends CI_Model {

protected $_table_name = "users";
protected $_primary_key = "id";
protected $_primary_filter = "intval";
protected $_order_by = "order";
public $rules = array(
  'email' => array(
   'field' => 'email',
   'label' => 'Email',
   'rules' => 'trim|required|valid_email|xss_clean'
  ),
  
  'password' => array(
   'field' => 'password',
   'label' => 'Password',
   'rules' => 'trim|required'
  ),
);

public $rules_admin = array(
  'name' => array(
   'field' => 'name',
   'label' => 'Name',
   'rules' => 'trim|required|xss_clean'
  ),
  
  'email' => array(
   'field' => 'email',
   'label' => 'Email',
   'rules' => 'trim|required|valid_email|callback__unique_email|xss_clean'
  ),
  
  'password' => array(
   'field' => 'password',
   'label' => 'Password',
   'rules' => 'trim|matches[password_confirm]'
  ),
  
  'password_confirm' => array(
   'field' => 'password_confirm',
   'label' => 'Confirm password',
   'rules' => 'trim|matches[password]'
  ),
);

protected $_timestamps = "FALSE";

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


function get($id = NULL, $single = FALSE){
if($id != NULL){
  $filter = $this->_primary_filter;
  $id = $filter($id);
  $this->db->where($this->_primary_key, $id);
  $method = 'row';
} elseif($single == TRUE) {
  $method = 'row';
} else {
  $method = 'result';
}

return $this->db->get($this->_table_name)->$method();
}
#2

[eluser]Renato Araujo[/eluser]
$id || $rules['password']['rules'] .= '|required';
#3

[eluser]Shiva666[/eluser]
Thanks that worked.




Theme © iAndrew 2016 - Forum software by © MyBB