Returning values from databse with public function

Codes here !

Moderators: egami, macek, gesf

Post Reply
zupko
New php-forum User
New php-forum User
Posts: 1
Joined: Mon Mar 26, 2018 10:07 pm

Mon Mar 26, 2018 10:25 pm

Hi,

I'm quite new to this kind of coding so I need help.
This is my code for reading value from database and returning values:

Code: Select all

 
   public function avtorizacije($user)
        {
            $sql = "SELECT * FROM uporabniki_avtorizacije WHERE userId=?";
            if( !$this->stmt = $this->mysqli->prepare($sql) )
                throw new Exception("MySQL Prepare statement failed: ".$this->mysqli->error);

            $this->stmt->bind_param("i", $user);
            $this->stmt->execute();
            $this->stmt->store_result();

            if( $this->stmt->num_rows == 0)
                return "";

            $this->stmt->bind_result($value);
            $this->stmt->fetch();

            return $value;
        }


And here is the error I get:
Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in ...

I need to return all values from selected row in database.

Please help...

Post Reply