
Best Answer kicken, 26 December 2014 - 08:33 PM
public function profile_view($user_id = null) { $stmt = $this->_db->prepare('SELECT memberID,username,email,profile_pic,active FROM members WHERE memberID = :user_id AND active="YES"'); $params = array(':user_id' => $user_id); var_dump($params); $stmt->execute($params); $row = $stmt->fetch(PDO::FETCH_ASSOC); var_dump($row); if ($row){ $user_det = (object)array( 'username'=> $row['username'] ,'email'=>$row['email'] ,'profile_pic'=>$row['profile_pic'] ,'id'=> $row['memberID'] ,'active'=>$row['active'] ); return $user_det; } else { var_dump($stmt->errorInfo()); } }
Since you only want one row, there is no need for the loop. Check the return value of the fetch call to be sure a row was actually found. I've added a few var_dumps at places that might be helpful in resolving your problem. Go to the full post
