1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[Crying] php output image problem is killing me

Discussion in 'Programming' started by Jangga, Jan 4, 2017.

  1. Jangga

    Jangga Junior Member

    Joined:
    Aug 8, 2016
    Messages:
    119
    Likes Received:
    4
    Gender:
    Male
    Occupation:
    Freelancer: A reWriter
    Location:
    Africa
    Please guys.... I'm completely blank why this is happening

    I am trying to get the image from my db which is stored like this: profile/image_name.jpg

    I simply fetch the array from db & echo
    But, no way. I know I'm doing it right cos I did same way in other section of my forum. In this part, the image displays but it sits at the upper left corner(see screenshot below). I don't know how to describe it so I can't do a Google search. Pls help me & tell me how to search it on Google too(English name)?

    Plsssss.... I'll buy u a beer if u help
     

    Attached Files:

  2. AryabhattZero

    AryabhattZero Power Member

    Joined:
    Jul 28, 2015
    Messages:
    763
    Likes Received:
    297
    Not able to understand what you want to output IMG or url?
    explain again
     
  3. Jangga

    Jangga Junior Member

    Joined:
    Aug 8, 2016
    Messages:
    119
    Likes Received:
    4
    Gender:
    Male
    Occupation:
    Freelancer: A reWriter
    Location:
    Africa
    I want to output the image so that users can see it. Check screenshot and perhaps, see my first post again, thanks
     
  4. RightFootFanatic

    RightFootFanatic Regular Member

    Joined:
    May 31, 2015
    Messages:
    319
    Likes Received:
    180
    Occupation:
    DevOps
    Location:
    Whimsyshire
    the image part seems to be broken.

    do you use an absolute or relative path to you image?
     
  5. kirila007

    kirila007 Newbie

    Joined:
    Nov 8, 2013
    Messages:
    39
    Likes Received:
    22
    I don't fully get what you are trying to do, the image is missing though.
     
  6. BlogPro

    BlogPro Power Member

    Joined:
    Apr 23, 2012
    Messages:
    521
    Likes Received:
    451
    OP, PM me a link to your page.

    You have the correct HTML tags, but the array being fetched has some issues - nothing that cannot be fixed.
     
  7. Jangga

    Jangga Junior Member

    Joined:
    Aug 8, 2016
    Messages:
    119
    Likes Received:
    4
    Gender:
    Male
    Occupation:
    Freelancer: A reWriter
    Location:
    Africa
    Thanks, man... I really don't know what u mean. The output code is something like this:

    $details = mysql_query("SELECT * FROM master WHERE username='$delle'");
    mysql_fetch_array($details);
    $out=$details["image"];
    echo $out;


    N:B==> in db, image is stored like this: " profile/image_name.jpg "

    I guess it's relative since it will automatically be appended to browserurl
    E.g blackhatworld.com/profile/image_name.jpg
     
  8. Jangga

    Jangga Junior Member

    Joined:
    Aug 8, 2016
    Messages:
    119
    Likes Received:
    4
    Gender:
    Male
    Occupation:
    Freelancer: A reWriter
    Location:
    Africa
    The image is not really missing because users with no image sees blank(which is correct). But those with image sees a tiny object at the upper left corner (see screen shot)

    Mr rightfootfanatic is saying image is broken..... I'm confused
     
  9. BlogPro

    BlogPro Power Member

    Joined:
    Apr 23, 2012
    Messages:
    521
    Likes Received:
    451
    If the image is stored like this "profile/image_name.jpg" - it won't work. Because the output would be blackhatworld.comprofile/image_name.jpg

    You need a preceding slash for it to be relative.
     
  10. AryabhattZero

    AryabhattZero Power Member

    Joined:
    Jul 28, 2015
    Messages:
    763
    Likes Received:
    297
    Echo '/'.$out;
    Now it will append to url
     
  11. Jangga

    Jangga Junior Member

    Joined:
    Aug 8, 2016
    Messages:
    119
    Likes Received:
    4
    Gender:
    Male
    Occupation:
    Freelancer: A reWriter
    Location:
    Africa

    I just tried it.... It still showing me the tiny stuff at upper left corner(see screenshot on my first post). It's like there is no way out..... Php is not fair
     
  12. AryabhattZero

    AryabhattZero Power Member

    Joined:
    Jul 28, 2015
    Messages:
    763
    Likes Received:
    297
    I don't see what tiny spot are you talking about.
    1) Provide more code (php & html)
    2) Give more screenshots explaining
     
  13. Jangga

    Jangga Junior Member

    Joined:
    Aug 8, 2016
    Messages:
    119
    Likes Received:
    4
    Gender:
    Male
    Occupation:
    Freelancer: A reWriter
    Location:
    Africa
    See the two screenshots.. One has an arrow pointing to the tiny spot. I'll provide the code collecting the image from db & output okay?
     

    Attached Files:

  14. Jangga

    Jangga Junior Member

    Joined:
    Aug 8, 2016
    Messages:
    119
    Likes Received:
    4
    Gender:
    Male
    Occupation:
    Freelancer: A reWriter
    Location:
    Africa
    code to query db & output is shown below.


    <?

    $TAMANO_PAGE = 100;

    $page = $_GET["page"];

    if (!$page) {

    $inicio = 0;

    $page=1;

    }

    else {

    $inicio = ($page - 1) * $TAMANO_PAGE;

    }

    $queryz = mysql_query("SELECT * FROM master ORDER BY id DESC limit $inicio,$TAMANO_PAGE");

    while ($register = mysql_fetch_array($queryz)) {


    echo "


    <tr>


    <td class=\"stylki go\"><font size=\"1\" face=\"verdana\">


    ". $register["name"] ."

    </td>


    <td class=\"stylki go\"><font size=\"1\" face=\"verdana\">


    ". $register["email"] ."

    </td>


    <td class=\"stylki go\"><font size=\"1\" face=\"verdana\">


    ". $register["subject"] ."



    </font></td>

    <td class=\"stylki go\"><font size=\"1\" face=\"verdana\">



    ". $register["comments"] ."


    </font></td>



    <td class=\"stylki go\"><img src='/'". $register["image"] ." border=\"0\" width=\"300\" height=\"200\"

    </td>


    <td class=\"stylki go\"><font size=\"1\" face=\"verdana\">



    ". $register["reply"] ."


    </font></td>


    <td class=\"stylki go\"><font size=\"1\" face=\"verdana\">";


    }


    ?>
     
  15. Jangga

    Jangga Junior Member

    Joined:
    Aug 8, 2016
    Messages:
    119
    Likes Received:
    4
    Gender:
    Male
    Occupation:
    Freelancer: A reWriter
    Location:
    Africa
    Any help forthcoming? Oh....
     
  16. BlogPro

    BlogPro Power Member

    Joined:
    Apr 23, 2012
    Messages:
    521
    Likes Received:
    451
    Can you post the html output being rendered.

    Also run a print for the output of the code.
     
  17. kirila007

    kirila007 Newbie

    Joined:
    Nov 8, 2013
    Messages:
    39
    Likes Received:
    22
    The image is missing/broken.

    Looking at your code, try to change
    PHP:
    '/'". $register["image"] ."
    to
    PHP:
    '/". $register["image"] ."'
     
  18. tb303

    tb303 Power Member

    Joined:
    Dec 18, 2011
    Messages:
    734
    Likes Received:
    388
    this line in your code
    Code:
    <td class=\"stylki go\"><img src='/'". $register["image"] ." border=\"0\" width=\"300\" height=\"200\"
    you're not closing the image tag. change it to this
    Code:
    <td class=\"stylki go\"><img src='/'". $register["image"] ." border=\"0\" width=\"300\" height=\"200\">
    you could also do it this way as it makes your code easier to read (for me anyway lol)
    Code:
    <td class='stylki go'><img src='".$register['image']."' border='0' width='300' height='200'> 
    also technically by adding a slash to the start of the url you fetch from the DB you make it absolute to root

    if your "profile" directory is a sub of where your php is located then you were right with no slash
    if profile is found in the www root then you need to add a slash at the start.
     
  19. Jangga

    Jangga Junior Member

    Joined:
    Aug 8, 2016
    Messages:
    119
    Likes Received:
    4
    Gender:
    Male
    Occupation:
    Freelancer: A reWriter
    Location:
    Africa
    Tried it & no headway. #stillStuck
     
  20. Jangga

    Jangga Junior Member

    Joined:
    Aug 8, 2016
    Messages:
    119
    Likes Received:
    4
    Gender:
    Male
    Occupation:
    Freelancer: A reWriter
    Location:
    Africa
    Ok. I used chrome & inspected the element. & the image output is okay

    <img src="profile/paul k 23445667788744.jpg" border="0" width="300" height="200">

    As, pointed out by tb303 above, my html code doesn't need a slash. Anyways, I took it off & it still didn't work. Image is still broken. I ran a Google search & I'm surprised there was no useful reply even on stackoverflow.....