Welcome Guest, Not a member yet? Register   Sign In
error using $vars C.I 1.6
#1

[eluser]vicman[/eluser]
Hi, i updated mi site, but now i can't use the param "$vars" in my views.

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined variable: vars

What i do?
#2

[eluser]Pascal Kriete[/eluser]
What is $vars? Where is it coming from? Some code would be nice.
#3

[eluser]Seppo[/eluser]
Working fine here (PHP 5.1.3)
#4

[eluser]vicman[/eluser]
I work with PHP 4.4xx, and not work me!!
i had that undo the update and back to CI 1.5.4
Sad
#5

[eluser]tonanbarbarian[/eluser]
vicman please provide an example of the controller calling the view and the view code so we can determine what the problem is
it is most likely there is a conflict because vars might be a reserved word now in CI 1.6

[edit] correction "vars" IS a reserved word in CI 1.6
Quick Reference
See the reserved function names on the right
never use the reserved function names for a function, method or variable as it may have strange results
#6

[eluser]stevepaperjam[/eluser]
I had the same problem when I upgraded to 1.6, some of the stuff in my views was referred to via $vars.

All I did was change...
Code:
$vars['thing']
to...
Code:
$thing
#7

[eluser]vicman[/eluser]
example

Controller
Code:
$data['body'] = $this->load->view('admin/historia/listhistoria',  $data2, true);
$this->load->view('template/plantillaAdmin.php', $data);


view
In the view i send more than one parameters.
Code:
<div id="dv_tratamiento" style="width:100%; &lt;? if ($vars['show'] === 'Normal') { ?&gt;height:288px; overflow:auto; min-height:50px; max-height:288px;&lt;? } ?&gt;">
                     &lt;?php $this->load->view('admin/historia/inc_tratamiento.php', $vars, false);?&gt;
                  </div>
#8

[eluser]Pascal Kriete[/eluser]
You don't need to use $vars, all of the values in the array are turned into variables. So if I have $data['show'] = "woot", and I pass this into the view, I can access it with $show.

Also, you don't need to to pass the variables again when loading a subview, they're available to this view automatically.

So your example becomes:
Code:
<div id="dv_tratamiento" style="width:100%; &lt;? if ($show === 'Normal') { ?&gt;height:288px; overflow:auto; min-height:50px; max-height:288px;&lt;? } ?&gt;">
                     &lt;?php $this->load->view('admin/historia/inc_tratamiento.php');?&gt;
</div>




Theme © iAndrew 2016 - Forum software by © MyBB