SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    don't display image

    i use this code for display image in my web page but IE doesn't show image

    PHP Code:
    <?php
    // connect to mysql server
    $link mysql_connect('localhost''root''');
    if (!
    $link) {
        die(
    'Not connected : ' mysql_error());
    }
    // connect to database server
    $db_selected mysql_select_db('admin'$link);
      
    if (!
    $db_selected) {
        die (
    'Database error : ' mysql_error());
    }
      
            
    $sql mysql_query("SELECT 'path' FROM image WHERE id='3' ");
       
    while(
    $rowmysql_fetch_array($sql)){
     
    $image =  $row['path'];

     
    // $image = $row['path'];
      
    echo'<img src="$image"/>';

    }
    ?>

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,494
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    Other browsers do?

  3. #3
    SitePoint Addict sdleihssirhc's Avatar
    Join Date
    Feb 2009
    Posts
    387
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Here's my guess as to what's happening: You're printing the <img> element like so:

    PHP Code:
    echo'<img src="$image"/>'
    You expect $image to be replaced with the actual path to the image, but your string is wrapped in single quotes. So I think your HTML source is just going to look like this (without the newlines, of course):

    HTML Code:
    <img src="$image"/>
    <img src="$image"/>
    <img src="$image"/>
    <img src="$image"/>
    Try changing your string so that it's inside double quotes instead:

    PHP Code:
    echo "<img src=\"$image\"/>"
    I'm the web overlord for Graphic Business Systems

  4. #4
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,494
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by sdleihssirhc View Post
    You expect $image to be replaced with the actual path to the image, but your string is wrapped in single quotes.
    Eagle eyes! Very good catch.
    So I guess the answer to my question is: no, the images didn't show up in any browser.


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
  •