Undefined index: URL [APP/View/Clients/index.ctp, line 90]

1.7k Views Asked by At

I have been asked to work on aplication someone else has created with cakePHP. I am new to cakePHP.The application shows the following errors

Notice(8):

    if(isset($client[0]) && $client[0]['contacts']['type_of']==3 && $var=='clients_with_contacts' && $this->Paginator->current()==1){
                                echo '<td style="background:lightblue">'.$client[0]['Client'][$field].'</td>';

include - APP/View/Clients/index.ctp, line 90
View::_evaluate() - CORE/Cake/View/View.php, line 947
View::_render() - CORE/Cake/View/View.php, line 909
View::render() - CORE/Cake/View/View.php, line 471
Controller::render() - CORE/Cake/Controller/Controller.php, line 948
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 194
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 162
[main] - APP/webroot/index.php, line 112

There is a ton of code.If you can think of anything let me know.

2

There are 2 best solutions below

2
On

One possible solution is to check for variables '$var' and '$client[0]['contacts']['type_of']' in the condition, like this:

if(isset($client[0]['contacts']['type_of']) && $client[0]['contacts']['type_of']==3 && isset($var) && $var=='clients_with_contacts' && $this->Paginator->current()==1){

echo '<td style="background:lightblue">'.$client[0]['Client'][$field].'</td>';

}
4
On

In ClientsController, check $client, and $var have been transferred correctly through :

$this->set ('client', $variable1);
$this->set ('var', $variable2);

or

$this->set (array ('client' => $variable1, 'var' => $variable2));

If so, check all fields for $client array exists too. Also in your codes, if statement missed a } too.