![]() |
Passing 2 Variables to your view error - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Passing 2 Variables to your view error (/showthread.php?tid=43857) |
Passing 2 Variables to your view error - El Forum - 07-25-2011 [eluser]BenSeagrave[/eluser] I googled how to pass 2 variables to your view file and someone told me to make an assoc array and include the variables inside of the array and pass the assoc array to the view. But i'm getting an error, Can someone tell me what i'm doing wrong? Here is my controller : Code: <?php The includes/template view file is just: Code: <?php This worked before I had the assoc array passing both the varibles. and this is the part of the view file that is loaded as the main_content at the moment: Code: <article> This is only a snippet of the main content as the rest of the file is pointless. The error i'm getting from my browser is: A PHP ERROR WAS ENCOUNTERED Severity: Notice Message: Undefined variable: main_content Filename: includes/template.php Line Number: 5 I don't understand what is wrong!! Can someone help ![]() Passing 2 Variables to your view error - El Forum - 07-25-2011 [eluser]portgaz[/eluser] Code: <?php Code: <article> I never tested this but i hope this helps! ![]() Passing 2 Variables to your view error - El Forum - 07-25-2011 [eluser]Mirge[/eluser] portgaz is correct. Since you're wondering why you're not able to retrieve data that you THINK you should be able to access, you'd start generally by looking where you're loading the view: Code: $this->load->view('includes/template', $data); Then, seeing that you ARE passing $data... you'd see what $data contained. Code: print_r($data); And there, you would have found your answer ![]() |