Jump to content

Help with PHP Syntax code error


GSMACK74

Recommended Posts

I am integrating phpBB with another system and trying to show user avatars in posts from member records in another system. The member ID's are kept in synch in both systems. 

 

I am however getting the the dreaded "Call to a member function on a non-object " on the 7th line down in the code listed below "$result = $db->sql_query($sql);".

 

I am sure it's my lack of php knowledge and a syntax error somewhere, but I can't find what I am doing wrong. can someone please take a few minutes and have a looksie?  I tried posting this on phpBB forums but nobody responded.

 

Thanks

 

 

function get_user_avatar($u_ID)
{
   // GRAB AVATAR FROM MEMBERSHIP
   //------------------------------------------------------------------------------
   // Return Prime Photo & Sex from Profile
   $sql = 'SELECT PrimPhoto, Sex FROM Profiles WHERE ID='.$u_ID;
   $result = $db->sql_query($sql);
   $row = $db->sql_fetchrow($result);
   $db->sql_freeresult($result);
   $uPhoto = $row['PrimPhoto'];
   $uSex = $row['Sex'];
   
   if ($uPhoto == 0)
   {
      // No Avatar set so return the default male or female avatar
      if ($uSex == 'male'){
         $avatar_img = '<img src="http://mysite/man_medium.gif">';
      } else {
         $avatar_img = '<img src="http://mysite/woman_medium.gif">';
      }
   } else {
      // Return Avatar from Media table
      $sql = 'SELECT med_file FROM media WHERE media.med_id='.$uPhoto;
      $result = $db->sql_query($sql);
      $row = $db->sql_fetchrow($result);
      $db->sql_freeresult($result);
      $avatar_img = $row['PrimPhoto'];
      if (!empty($avatar_img ))
      {
         $avatar_img = '<img src="http://mysite/images/profile/'.$u_ID.'/'.$avatar_img.'">';
      } else {
         $avatar_img = '';
      }
      
   }
   return $avatar_img;   
}

 

Link to comment
https://forums.phpfreaks.com/topic/119513-help-with-php-syntax-code-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.