Welcome Guest, Not a member yet? Register   Sign In
Database Query result frustration

(This post was last modified: 04-12-2020, 10:23 AM by stlake2011.)

Hi all,

Am having a hell of a time trying to figure out whats going wrong here or what maybe i am missing. Been troubleshooting this error for far to many hours now.

I am writing a custom login library, but when I query the database for a username/email address, the query is not returning any results at all. 
I ran the same query itself in phpmyadmin and it is finding the result expected there.

So I figure I will put it here and maybe you people might see something my blurring eyes are missing.

Below is the relevant piece code:
PHP Code:
            $sql "SELECT user_id,user_group,username,passwd FROM users WHERE username=?";

            $db_result $this->db->query($sql,[$username]);
if((!is_array($db_result)) || (!is_object($db_result)) || (count($db_result->getResult() <= 0) || (count($db_result->getResult() > 1)))) {
                return $result = [
                    'status' => FALSE,
                    'header' => 'LOGIN DENIED',
                    'message' => 'Your Login Attempt has been denied. We could not find your login details!'

Found the error!
It was in the IF statement itself. It was all syntax errors with the count function that somehow were not being thrown. Not sure if thats a PHP Issue but perhaps the developers could write a wrapper around count for the databases that would simplify it further?

Also one thing that puzzles me though is why is_array() is returning false on the result array when its clearly true?

Messages In This Thread
Database Query result frustration - by stlake2011 - 04-12-2020, 08:48 AM

Theme © iAndrew 2016 - Forum software by © MyBB