Jump to content
Sign in to follow this  
KalashaLv

Fatal error!

Recommended Posts

Sveiki, nāku pēc palīdzības saistībā ar login darbību!

draugs nesen izveidoja man jaunus failus priekš login!

Tik šodien patestēju un izet šādu rindiņu!!

Fatal error: Call to a member function query() on a non-object in ../web.class.php on line 9

 

Kāds nevarētu pateikt kas te ir nepareizi?

 

config fails;

 

<?php 
    define('SITE_NAME', 'TEST.LV');
    define('SITE_URL', 'http://localhot');
    define('SITE_FORUM_URL', 'http://localhost/3.xforums');
    define('SITE_PATH', $_SERVER['DOCUMENT_ROOT'].'/');
    $db = new mysqli('localhost', '..', '..', '..');
    require '../classes/web.class.php';
    $web = new Web($db);
    if($web->isLoggedIn()) $web->redirect(SITE_FORUM_URL);
?>

 

web.class fails

 

<?php 
    class Web {
        private $db;
        public function __constuct($db) {
            $db = $this->db;
        }
        public function isLoggedIn() {
            if(isset($_COOKIE['member_id']) && isset($_COOKIE['pass_hash'])) {
                $kverijs = $this->db->query('SELECT * FROM `members` WHERE `member_id` = '.$_COOKIE['member_id'].' AND `member_login_key` = "'.$_COOKIE['pass_hash'].'";');
                $checker = $kverijs->num_rows == 1 ? true : false;
            }
            else $checker = false;
            return $checker;
        }
        public function redirect($url) {
            return header('Location:'.$url);
        }
    }
?>

 

 

izpalīdzat lūdzu :)

 

Share this post


Link to post
Share on other sites

u wut?

function __construct($db) 
{
	$this->db = $db;
}

1. konstruktoram nav jēga no public.
2. Tev $db = $this->db vietām sajaukts bija.
3. iekšs __construct metodes nosaukuma kļūda.

Edited by Arthur Vasilyev
  • Upvote 3

Share this post


Link to post
Share on other sites
5 minutes ago, Arthur Vasilyev said:

u wut?


function __constuct($db) 
{
	$this->db = $db;
}

Tas pats

 

20 minutes ago, Arthur Vasilyev said:

u wut?


function __construct($db) 
{
	$this->db = $db;
}

1. konstruktoram nav jēga no public.
2. Tev $db = $this->db vietām sajaukts bija.
3. iekšs __construct metodes nosaukuma kļūda.

Tagad viņš strādā, bet vienalga, ielogojies vai nē, viņš vnk pārmet uz forumu

Share this post


Link to post
Share on other sites

Pis Tevi. Pat plusu neielika.... 

Debugo. Pārbaudi, ko kverijs atgriež abos variantos. 

Nekad vairs nevienam nepalīdzēšu

Edited by Arthur Vasilyev
  • Upvote 8

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.