![]() |
[Closed] error Undefined variable: query - 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: [Closed] error Undefined variable: query (/showthread.php?tid=60567) |
[Closed] error Undefined variable: query - El Forum - 04-24-2014 [eluser]riwakawd[/eluser] Hello I have created a library for my users login what gets and updates stuff to and from data base. I am getting a error undefined variable : Query line 8 which in the one in the public function construct. Not sure if have set the query correct for both public function and function login. Code: public function __construct() { [Closed] error Undefined variable: query - El Forum - 04-24-2014 [eluser]www.sblog.in[/eluser] You have used $query inside contructor but how or from where this variable is coming ? [Closed] error Undefined variable: query - El Forum - 04-24-2014 [eluser]Tim Brownlaw[/eluser] I'm only going to address the "undefined variable issue". The rest scares me... ie your constructor! Now, Is it telling you which variable is undefined? Are you checking things like if - $this->session->userdata['user_id'] actually exists... and $this->request->server['REMOTE_ADDR'] exists? [Closed] error Undefined variable: query - El Forum - 04-24-2014 [eluser]riwakawd[/eluser] [quote author="Tim Brownlaw" date="1398407924"]I'm only going to address the "undefined variable issue". The rest scares me... ie your constructor! Now, Is it telling you which variable is undefined? Are you checking things like if - $this->session->userdata['user_id'] actually exists... and $this->request->server['REMOTE_ADDR'] exists? [/quote] How would you set it out in library file? I have been looking on internet thats how I got it. I also got token working. [Closed] error Undefined variable: query - El Forum - 04-24-2014 [eluser]Tim Brownlaw[/eluser] That's for another day.... You've not answered my question regarding your initial question! And that's good that you got your tokens working! [Closed] error Undefined variable: query - El Forum - 04-24-2014 [eluser]riwakawd[/eluser] [quote author="Tim Brownlaw" date="1398408448"]That's for another day.... You've not answered my question regarding your initial question! And that's good that you got your tokens working![/quote] I created separate auth library [Closed] error Undefined variable: query - El Forum - 04-25-2014 [eluser]InsiteFX[/eluser] If he is accessing the database in a Library then he needs to get the CI Super object. Code: private $_ci; // The CI Super object [Closed] error Undefined variable: query - El Forum - 04-25-2014 [eluser]riwakawd[/eluser] [quote author="InsiteFX" date="1398437915"]If he is accessing the database in a Library then he needs to get the CI Super object. Code: private $_ci; // The CI Super object [/quote] Have been watching some more videos on how to get session data I think this is OK just to grab the username and ip address just so can store the ip in user. I ts going to be easier when I set up my maintenance config in future. Code: function get_db_session_data() { |