ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Default Avatars in Discussion Forum Templates PHP

August 27, 2014 11:11am

Subscribe [1]
  • #1 / Aug 27, 2014 11:11am

    exida

    3 posts

    My PHP skills are not that good and I have been struggling to get some code to work once I have upgraded to EE2.

    For EE1, I had this code to display avatars on certain forum pages that did not support avatars. I also wanted to display a default avatar as well.

    Here is the EE1 code

    <?php global \$DB;
    \$query = "SELECT member_id, avatar_filename FROM exp_members WHERE screen_name='" . \\\\$DB->escape_str('{author}') . "'";
    \$res = \$DB->query(\$query);
    if(\$res->row['avatar_filename'] != '') {
       echo "<img >row['avatar_filename'] . "\" >";
    } else {
       echo 'http://images.mydomain.com/images//anon_avatar.png';
    }
    ?>

    Here is my updated EE2 code that does not seem to work:

    <?php 
    \$query = $this->EE->db->query("SELECT member_id, avatar_filename FROM exp_members WHERE screen_name='" . \\\\$this->db->escape_str('{author}') . "'");
    if(\$query->row['avatar_filename'] != '') {
       echo "<img >row['avatar_filename'] . "\" >";
    } else {
       echo 'http://images.mydomain.com/images/anon_avatar.png';
    }
    ?>

    Can someone help?  Thank you!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases