SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2013
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unable to display image!?

    Hi guys,
    I have been trying to get my comment system to show user images on submit...

    This is the code i'm using -

    PHP Code:
    $url "../".$_SESSION['avatar']."";
            
            return 
    '
            
                <div class="comment">
                    <div class="avatar">
                        <img src="'
    .$url.'" />
                    </div>
                    
                    <div class="name">'
    .$d['name'].'</div>
                    <div class="date" title="Added at '
    .date('H:i \o\n d M Y',$d['dt']).'">'.date('d M Y',$d['dt']).'</div>
                    <p>'
    .$d['body'].'</p>
                </div>
            '
    ;
        } 
    This works perfectly but the image doesn't display on submit. However it displays when the page is refreshed...

    In the image src all that is currently display before the page is refreshed is "../" but not the full link?

    It would be nice if i could echo the variable "$url" and it would work but i don't how know if that is possible in the return function.

    Can anyone please help me with this?

  2. #2
    SitePoint Enthusiast Belsnickle's Avatar
    Join Date
    Feb 2012
    Location
    Chico, CA
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Without more context or an example there's not much here to work on so here's my assumption of what might be going on:

    Session content is sent in page headers, if your headers aren't being resent (like say this is included dynamically) you probably won't see your updated session information. Refreshing the page would reinitialize the sending of the headers.

    Check if the session variable avatar is_empty and then if it returns true use the variable that fills it instead and it might work. You can do this because you've already verified that it is getting populated just not in time for your return call.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •