Welcome Guest, Not a member yet? Register   Sign In
[URGENT HELP]Severity: Notice Message: Undefined variable:user_id Filename: controllers/users.php
#1

[eluser]chazy (aldever calvo)[/eluser]
hi.. i can't fix on what's happening on my CRUD in edit... this is my code it also says that i got error in line 63 and 65...

Quote:A PHP Error was encountered

Severity: Warning

Message: Missing argument 1 for Users::edit()

Filename: controllers/users.php

Line Number: 63

this is my code:

63: function edit($user_id)
64: {
65: $data['id'] = $this->user_model->GetUser(array('user_id' => $user_id));
66: if (!$data['id']) redirect('users');
67: }
#2

[eluser]Twisted1919[/eluser]
That's a common mistake .
Your method is like
Code:
function edit($user_id)
{
//blah blah blah
}
But this means we are forced to provide an user id in the url , something like /user/edit/1 but if we don't provide that 1 and the url is /url/edit that of course, the $user_id var is undefined.
You need to correct this like :
Code:
function edit($user_id='')
{
   if(empty($user_id) || !is_numeric($user_id) || $user_id < 1)
   {
      redirect('users');
   }
   //continue processing because from now on we really have a valid $user_id.

}




Theme © iAndrew 2016 - Forum software by © MyBB