Returning values from databse with public function

Codes here !

Moderators: egami, macek, gesf

Post Reply
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


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);

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


            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