Undefined Variable problem - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Undefined Variable problem (/showthread.php?tid=48745) |
Undefined Variable problem - El Forum - 01-27-2012 [eluser]joeizang[/eluser] hello everyone, happy new year first of all. I have a question. I am developing an application using CI 2.10 with the following libraries: ion_auth, phil sturgeons template library. At the moment this is all the libraries I will be using for now. the problem I have is that I created a form and have validation errors sent to a partial as a variable from my controller like so: Code: //Controller method processing form Code: //this is a snippet from the partial on the view but all I get in the regions where I have data from the controller I get this: Code: A PHP Error was encountered But when there is an error from trying to login, the errors appear accordingly so where am I missing it? Thanks for y'all help;-) Undefined Variable problem - El Forum - 01-27-2012 [eluser]InsiteFX[/eluser] Try passing $data not $data1 Undefined Variable problem - El Forum - 01-27-2012 [eluser]joeizang[/eluser] That did not work insiteFX. the errors even worse since there ain't that variable in my method anyways but thanks for trying though. Undefined Variable problem - El Forum - 01-27-2012 [eluser]PhilTem[/eluser] You get the error before submitting the form? For me it looks at least pretty obvious. If the if-case isn't validated to TRUE, then it won't get inside the if-part. So no variable $data1 will be generated therefore the row Code: ->build('layouts/default',$data1); accesses a variable that doesn't exist (undefined variable). That's prompted by CI since it's very sensitive towards missing variables. Try to initiate $data as an empty array before you have the if-part Undefined Variable problem - El Forum - 01-27-2012 [eluser]InsiteFX[/eluser] This is what PhilTem is saying to do. Code: $data1 = array(); Undefined Variable problem - El Forum - 01-30-2012 [eluser]joeizang[/eluser] Hey InsiteFX, thanks for helping me thus far. I did just what you said and still I get that error. I thought I should maybe do this to data1: Code: $this->data1 = array(); Undefined Variable problem - El Forum - 01-30-2012 [eluser]InsiteFX[/eluser] Try placing a comma on the end. Code: $data1 = array( You may need to assign the validation_errors() to a varianle first then pass that in your $data1 array. Undefined Variable problem - El Forum - 01-30-2012 [eluser]CroNiX[/eluser] Why pass it at all? In the view, just echo validation_errors(). If there are no errors, nothing will print. Undefined Variable problem - El Forum - 01-31-2012 [eluser]joeizang[/eluser] Cronix, thanks for that. why I was going the other way was for a while there using the template library and a lower version of CI (CI 2.0.3) I just couldn't see the validation_errors() echoing in my view but I could do that if I used the method that had been giving all the trouble. Now using 2.10 I just continued using the code I had written before so thanks for stating what should've been obvious. Big thanks to InsiteFX and PhilTerm for taking the time to talk to me about this. Much obliged. |