Undefined variable: MyBBI + Call to a member function login() on a non-object |
[eluser]Evollution[/eluser]
Call to a member function isLoggedIn() on a non-object in in/application/controllers/welcome.php on line 14 line 14 : echo ($MyBBI->isLoggedIn()) ? 'You are logged in' : 'You are not logged in'; if i echo this code on index.php it works :\
[eluser]Evollution[/eluser]
+ i get the same error if i post : if($mybb->user['uid']) { // If the user if logged in, display a welcoming message. echo "Welcome back ".$mybb->user['username']."!<br />"; echo "Thanks for logging in."; } "Message: Undefined variable: mybb"
[eluser]Evollution[/eluser]
on index.php Code: <?php on welcome.php: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); im using http://phpdave.com/MyBBIntegrator/Start to integrate mybb with CI the problem i think is becouse of globals .
[eluser]Twisted1919[/eluser]
Why the heck would you instantiate the class in your index.php file ? You do realize that if you're doing so you are losing all of the benefits of using oop programming right ? Go on the right way, have something like: Code: class MY_Controller extends CI_Controller{ Then extend all your controllers from MY_Controller and you magically have access to $this->mybb in each method of the child classes extended from your main controller. With other words, you would have: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); I noticed other posts of yours, you really need to understand how all of this "oop programming" works, otherwise, you will always be hitting these brick walls on simple issues.
[eluser]Evollution[/eluser]
mersi dar e posibil sa fac sub forba de librarie ca sa nu copii codul de fiecare data ?!
[eluser]Twisted1919[/eluser]
Cum ti-am aratat mai sus e varianta perfecta, nu vei copia codul de fiecare data, pt ca, codul e in MY_Controller, si tu extinzi fiecare controller din acel MY_Controller nu din CI_Controller deci ai access direct la variabilele si metodele din MY_Controller utilizand variabila $this. In php oop, daca extinzi o clasa din alta, automat clasa aia preia toate atributele clasei parinte. Ia urmatorul exemplu: Code: class parinte{
[eluser]Evollution[/eluser]
nam inteles eu ceva ![]() Code: class MY_Controller extends CI_Controller{ asta trebuie so postez ca librarie
[eluser]Evollution[/eluser]
deci am creat in app/core my_controller.php Code: <?php si acum primesc eroarea : Fatal error: Call to a member function simple_select() on a non-object in /home/fifagoc1/public_html/go/forum/inc/class_datacache.php on line 80 Line 80 // Database cache $query = $db->simple_select("datacache", "title,cache"); while($data = $db->fetch_array($query)) { $this->cache[$data['title']] = unserialize($data['cache']); } } } ceva idei :|
[eluser]Twisted1919[/eluser]
Din cate imi dau eu seama, cred ca nu se poate conecta la baza de date, poate incerci setarile din nou ? N-am nici ceea mai vaga ideea de ce ar merge asha pentru ca eu unu nu folosesc forumuri . Interesant este, cand iti da eroarea asta ? cand instantiezi $this->mybb=? sau ? |
Welcome Guest, Not a member yet? Register Sign In |