Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,447
    Thanks
    71
    Thanked 102 Times in 101 Posts

    Get image from query

    I've tried everything I know with this. From ".$blah['value']." to {$blah['value']}
    The $usrow is successfully pulling the value from the database because I echo'd it and it works.
    I am guessing maybe to set it as a variable first?

    The page loads with this coding below but there is no image and in the source code it shows images/.png

    Oh and also some of the things like {} and ". ." break the page and it errors out.

    Thanks

    PHP Code:
    <div class="image"><img src="http://www.codingforums.com/images/<?php ".$usrow[class]." ?>.png" alt="" /></div>
    Last edited by myfayt; 05-04-2014 at 05:45 PM.
    Been a sign maker for 7 years. My business:
    American Made Signs

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,219
    Thanks
    23
    Thanked 605 Times in 604 Posts
    <div class="image"><img src="http://www.codingforums.com/images/<?php echo $usrow['class']; ?>." ?>.png" alt="" /></div>
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #3
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,447
    Thanks
    71
    Thanked 102 Times in 101 Posts
    I thought that would work, but nothing, still getting this: <img src="http://www.newrodgame.com/createchar/images/.png" alt="" />
    Been a sign maker for 7 years. My business:
    American Made Signs

  • #4
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,447
    Thanks
    71
    Thanked 102 Times in 101 Posts
    Whew, finally got it to work. Here is what I had to do.

    PHP Code:
    $sel_image = $usrow['class'];

    <div class="image"><?php echo "<img src=\"http://www.newrodgame.com/createchar/images/$sel_image.png\">"?></div>
    Been a sign maker for 7 years. My business:
    American Made Signs

  • #5
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,327
    Thanks
    60
    Thanked 525 Times in 512 Posts
    Blog Entries
    4
    You need to var_dump($usrow['class']);

    I'm assuming the class column in your table contains the file name and not the actual file blob?
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

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