OK, that's more than weird...
Here's my code :
public function results($id,$pattern=3)
{
$this->load->library('session');
if (!$this->session->userdata('logged_in'))
{
$this->session->set_flashdata('return_url',$this->uri->uri_string());
redirect('log/in','refresh');
}
else
{
$this->load->model('projects');
$proj = (array)$this->projects->getProjectById($id);
print_r($proj);
$progressPercentage = number_format((float)( ($proj['progress'] * 100) / $proj['total'] ), 2, '.', '');
}
}
Now, here's the issue :
- When NO
$pattern
is passed to the controller, the whole thing works fine. When I pass some parameter, like
mysite.com/project/results/45/4
(pattern=4), I'm getting the following error :A PHP Error was encountered Severity: Notice Message: Undefined index: progress Filename: controllers/project.php Line Number: 75
The weird thing is that both $id
and $pattern
are "read" fine.
When I'm print_r
ing $proj
just before the line concerning undefined index
this the results I'm getting :
Array ( [id] => 21240 [email] => my@gmail.com [url] => somewebsite.com [domains] => another_domain [progress] => 198 [total] => 199 [alias] => Test Project #3 [status] => complete )
And well as you can obviously see for yourself, the progress
index is perfectly there.
So, what could the issue be? Is that any weird know CI bug?
This is what var_dump($proj,$proj['progress']);
gives :
array(8) {
["id"]=>
string(5) "21240"
["email"]=>
string(20) "my@gmail.com"
["url"]=>
string(27) "somewebsite.com"
["domains"]=>
string(84) "another_domain"
["progress"]=>
string(3) "198"
["total"]=>
string(3) "199"
["alias"]=>
string(15) "Test Project #3"
["status"]=>
string(8) "complete"
}
string(3) "198"