Topic: Missing <DIV> in profile.php

in profile.php there is a closing DIV missing.

There are 2 instances of this:

                        <legend><?php echo $lang_profile['User activity'] ?></legend>
                        <div class="infldset">

It should be:


                        <legend><?php echo $lang_profile['User activity'] ?></legend>
                        <div class="infldset"></div>

2 (edited by bingiman 2007-02-18 23:16)

Re: Missing <DIV> in profile.php

I have also noticed that in viewtopic.php this line:

<dd class="postavatar"><?php echo $user_avatar ?></dd>

requires an ID if the user has not selected an avatar, so I had to format it in this way to be W3C Compliant.

<dd id="avatar" class="postavatar"><?php echo $user_avatar ?></dd>

3 (edited by guardian34 2007-02-18 23:37)

Re: Missing <DIV> in profile.php

Profile 1:

            <div class="inform">
                <fieldset>
                <legend><?php echo $lang_profile['User activity'] ?></legend>
                    <div class="infldset">
                        <dl>
<?php if ($posts_field != ''): ?>                            <dt><?php echo $lang_common['Posts'] ?>: </dt>
                            <dd><?php echo $posts_field ?></dd>
<?php endif; ?>                            <dt><?php echo $lang_common['Last post'] ?>: </dt>
                            <dd><?php echo $last_post ?></dd>
                            <dt><?php echo $lang_common['Registered'] ?>: </dt>
                            <dd><?php echo format_time($user['registered'], true) ?></dd>
                        </dl>
                        <div class="clearer"></div>
                    </div>
                </fieldset>
            </div>

Profile 2:

                <div class="inform">
                    <fieldset>
                        <legend><?php echo $lang_profile['User activity'] ?></legend>
                        <div class="infldset">
                            <p><?php echo $lang_common['Registered'] ?>: <?php echo format_time($user['registered'], true); if ($pun_user['g_id'] < PUN_GUEST) echo ' (<a href="moderate.php?get_host='.pun_htmlspecialchars($user['registration_ip']).'">'.pun_htmlspecialchars($user['registration_ip']).'</a>)'; ?></p>
                            <p><?php echo $lang_common['Last post'] ?>: <?php echo $last_post ?></p>
                                <?php echo $posts_field ?>
<?php if ($pun_user['g_id'] < PUN_GUEST): ?>                            <label><?php echo $lang_profile['Admin note'] ?><br />
                            <input id="admin_note" type="text" name="admin_note" value="<?php echo pun_htmlspecialchars($user['admin_note']) ?>" size="30" maxlength="30" /><br /></label>
                        </div>
<?php endif; ?>                    </fieldset>
                </div>

Looks fine to me.

Edit: That is, the closing </div> is right before the </fieldset> tag.

4 (edited by guardian34 2007-02-18 23:43)

Re: Missing <DIV> in profile.php

bingiman wrote:

I have also noticed that in viewtopic.php this line:

<dd class="postavatar"><?php echo $user_avatar ?></dd>

None of the other lines there have IDs? Can you provide any links for this?

Edit: On a different note, isn't this piece from viewtopic.php redundant?

        else
            $user_avatar = '';

Re: Missing <DIV> in profile.php

Actually I spent a little more time with it and figured out that this is the area that requires the closing DIV

                $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id!='.PUN_GUEST.' ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());

                while ($cur_group = $db->fetch_assoc($result))
                {
                    if ($cur_group['g_id'] == $user['g_id'] || ($cur_group['g_id'] == $pun_config['o_default_user_group'] && $user['g_id'] == ''))
                        echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
                    else
                        echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
                }

?>
                            </select>
                            <input class="button" type="submit" name="update_group_membership" value="<?php echo $lang_profile['Save'] ?>" />
                        </div>
                    </fieldset>
                </div>

should be:

                $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id!='.PUN_GUEST.' ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());

                while ($cur_group = $db->fetch_assoc($result))
                {
                    if ($cur_group['g_id'] == $user['g_id'] || ($cur_group['g_id'] == $pun_config['o_default_user_group'] && $user['g_id'] == ''))
                        echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
                    else
                        echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
                }

?>
                            </select>
                            <input class="button" type="submit" name="update_group_membership" value="<?php echo $lang_profile['Save'] ?>" />
                        </div>
                    </fieldset>
                </div></div>

I am 100% sure this time. Notice the last 2 divs after the last fieldset. The problem was this: If I am logged in as admin it worked fine but if I logged in as a user I then saw the problem with the missing closing div.

Bingiman

Re: Missing <DIV> in profile.php

guardian34 wrote:
bingiman wrote:

I have also noticed that in viewtopic.php this line:

<dd class="postavatar"><?php echo $user_avatar ?></dd>

None of the other lines there have IDs? Can you provide any links for this?

I still seems to be getting w3c errors with the above. If I sue an ID then it shows up as being used twice. The problem is if a user does not use an avatar then it shows up as an error in TIDY HTML Validator. If I use the id and the user then uses and avatar I still get a problem. Maybe there should be some sort of if statement around that line. I am not a coder so I really wouldn't know what to put there but I do know it is a problem. I even get it on this site.

Bingiman

Re: Missing <DIV> in profile.php

Edit: On a different note, isn't this piece from viewtopic.php redundant?

        else
            $user_avatar = '';

Yes, I have 2 instances of it.

8 (edited by guardian34 2007-02-18 23:51)

Re: Missing <DIV> in profile.php

Edit:

bingiman wrote:

The problem was this: If I am logged in as admin it worked fine but if I logged in as a user I then saw the problem with the missing closing div.

Um, isn't the part you posted only visible to admins?

Re: Missing <DIV> in profile.php

Yes it is but for some reason I get those errors. I am also using the latest version of punBB. Unfortunately I am running it on my local site so I can't provide you with a link. Hopefully I can have the site in production by the middle of the week so I can show you what I mean.

Cheers!
Bingiman

Re: Missing <DIV> in profile.php

My profile page validates with w3.org?

Re: Missing <DIV> in profile.php

Have you installed any mods? My profile page validates fine as admin, user or guest, all divs are closed properly and I don't have duplicates of

        else
            $user_avatar = '';

Re: Missing <DIV> in profile.php

soonotes wrote:

I don't have duplicates of

        else
            $user_avatar = '';

Not duplicates, but it's already defined earlier:

while ($cur_post = $db->fetch_assoc($result))
{
    $post_count++;
    $user_avatar = '';

Re: Missing <DIV> in profile.php

bingiman wrote:

Unfortunately I am running it on my local site so I can't provide you with a link.

How are you validating your pages?

Re: Missing <DIV> in profile.php

I got ya. It's being redefined if certain conditions don't apply hence the else

You have another thread about avatars not showing up. Again, have you installed any mods?

15 (edited by bingiman 2007-02-19 00:36)

Re: Missing <DIV> in profile.php

guardian34 wrote:
bingiman wrote:

Unfortunately I am running it on my local site so I can't provide you with a link.

How are you validating your pages?

I am using FireFox with the HTML Validator plugin.

btw: I sorted out the avatar issue. Silly mistake on my part.

Re: Missing <DIV> in profile.php

Ok, I pulled the error from the FF HTML Validator screen and this is what I get:

line 179 column 6 - Warning: trimming empty <dd>

and it refers to this line:

<dd class="postavatar"></dd>

I get this error when I am logged in *only* as a user who does not have an avatar. If I select an avatar, then the error is gone. This again is in the viewtopic.php file. Hope I explained it correctly now.

Bingiman

Re: Missing <DIV> in profile.php

I think I found a solution to eliminate this issue.

in viewprofile.php

I changed this:

        if ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0')
        {
            if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif'))
                $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif" '.$img_size[3].' alt="" />';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg'))
                $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg" '.$img_size[3].' alt="" />';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png'))
                $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png" '.$img_size[3].' alt="" />';
        }
        else
            $user_avatar = '';

to this:

        if ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0')
        {
            if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif'))
                $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif" '.$img_size[3].' alt="" />';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg'))
                $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg" '.$img_size[3].' alt="" />';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png'))
                $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png" '.$img_size[3].' alt="" />';
        }
        else
            $user_avatar = '<img alt="" src="img/noimage.gif"></img>';

so even if the user does not select an avatar, one will be provided. If they do select one, then of course it overrides the default.

Bingiman

Re: Missing <DIV> in profile.php

bingiman wrote:

Ok, I pulled the error from the FF HTML Validator screen and this is what I get:

line 179 column 6 - Warning: trimming empty <dd>

and it refers to this line:

<dd class="postavatar"></dd>

Warning are not the same as errors. Tidy is just stating that there isn't anything inside that element (because the user being displayed doesn't have an avatar, or the user viewing the page is not displaying them).

Re: Missing <DIV> in profile.php

You could use

            $user_avatar = '<img alt="" src="img/noimage.gif"></img>';

but that will probably leave you with unwanted white space between the user title and the rest of the user info. If you're worried about the warning try this instead: Replace

<dd class="postavatar"><?php echo $user_avatar ?></dd>

with

        <?php if ($user_avatar != '') echo '<dd class="postavatar">'.$user_avatar.'</dd>' ?>

Re: Missing <DIV> in profile.php

benjiman, why not this?

<img alt="" src="img/noimage.gif" />

While I'm nitpicking? soonotes, you might as well match the lines below that.

<?php if ($user_avatar != '') echo "\t\t\t\t\t".'<dd class="postavatar">'.$user_avatar.'</dd>'."\n" ?>

Re: Missing <DIV> in profile.php

True enough. smile

Re: Missing <DIV> in profile.php

Thanks for the help guys. big_smile

Bingiman

Re: Missing <DIV> in profile.php

Moved to Troubleshooting, since I can't find where it doesn't validate smile

Re: Missing <DIV> in profile.php

Well, I am lost. I am using an original copy of profile.php and I still get the error. When I click on the HTML Validator in FF it tells me this:

error:

line 195 column 7 - Warning: missing </div>

in profile.php it appears to be around the second instance of:

<legend>User activity</legend>
                        <div class="infldset">

I also don't get this when I am logged in as admin, only as a user under "Essentials" all the others are fine, by that I mean # Personal, Messaging, Personality, Display and Privacy. I've tried and tried but have not had any success solving it.

Cheers!
Bingiman

Re: Missing <DIV> in profile.php

Moved back to Bugs: you're right, there is a missing div smile
There's an endif and a closing div tag which need to be switched wink