1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP Echo Image

Discussion in 'Programming' started by jrp1, Jan 27, 2009.

  1. #1
    For some reason,

      echo "<img src=\"http://myimglink.com/img.png" border=0>"; 
    
    } 
    Code (markup):
    Isn't working for a PHP echo output. How can I fix this? Thanks in advance.
     
    jrp1, Jan 27, 2009 IP
  2. linkstraffic

    linkstraffic Well-Known Member

    Messages:
    388
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    133
    #2
     echo "<img src=\"http://myimglink.com/img.png\" border=0>"; 
    PHP:
    or

     echo '<img src="http://myimglink.com/img.png" border=0>'; 
    PHP:
     
    linkstraffic, Jan 27, 2009 IP
  3. jrp1

    jrp1 Active Member

    Messages:
    93
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Thanks man, worked like a charm.
     
    jrp1, Jan 27, 2009 IP
  4. cancer10

    cancer10 Guest

    Messages:
    364
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    linkstraffic is right but I personally prefer not to use double-quotes "" while echoing an image.
     
    cancer10, Jan 28, 2009 IP
  5. erebussymk

    erebussymk Greenhorn

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #5
    I can see output of
    echo "hello";
    But below is not working? Can somebody help me ?
    echo "<img src=\"dog.png\" height=10 width=10>";
     
    erebussymk, Sep 21, 2011 IP
  6. fortehlolz

    fortehlolz Banned

    Messages:
    111
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6

    echo '<img src="dog.png" height="10" width="10">';
     
    fortehlolz, Sep 21, 2011 IP
  7. erebussymk

    erebussymk Greenhorn

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #7
    Thanks fortehlolz. its now working. I have made mistake in image path location.
     
    erebussymk, Sep 21, 2011 IP
  8. Pathan

    Pathan Well-Known Member

    Messages:
    2,196
    Likes Received:
    218
    Best Answers:
    0
    Trophy Points:
    165
    #8
    what i can see is the problem was with double quotes. when you are using double quotes make sure not to use it again in the same case use single quote instead.
     
    Pathan, Sep 21, 2011 IP
  9. REtec

    REtec Peon

    Messages:
    61
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    just got to make sure to sanitize the string that is in the echo statement.

    What designer are you using for your coding? There are some pretty decent low cost applications (probably some free too) that catch coding errors like this.
     
    REtec, Sep 21, 2011 IP
  10. Zikkina KilRogg

    Zikkina KilRogg Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    HI guys,
    I`m trying my first page with Vertex free template. Can some one help me to change background color to an image.:confused:
    php index is:<style type="text/css"> body {font-family: '<?php echo $s5_fonts;?>',Helvetica,Arial,Sans-Serif ;background:#<?php echo $s5_page_bg ?>;}
    css template is: body { color:#333333; font-size:0.8em; line-height:140%;}

    Vertex have a choose color in vertex admin UI :(
    I tryed put image links, colors but nothing happend on the website :( in css i has allready change header color, some of shadows and more. But the image i can`t find it the right way, very pls HELP Me..

    Best regards
    Thanks in advance
    Zikkina KilRogg
     
    Last edited: Mar 6, 2012
    Zikkina KilRogg, Mar 6, 2012 IP
  11. MatrixName

    MatrixName Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Look there and help me to add here siza of image
    in line 11
    Here is the display ---> echo "<img src=\"images/" . $row['filename'] . "\" alt=\"\" /><br />";





    <?php
    // Grab the data from our people table
    $sql = "select * from njerz";
    $result = mysql_query($sql) or die ("Could not access DB: " . mysql_error());






    while ($row = mysql_fetch_assoc($result))
    {
    echo "<div class=\"picture\">";
    echo "<p>";


    // Note that we are building our src string using the filename from the database
    echo $row['fname'] . " " . $row['lname'] . "<br />";
    echo "<img src=\"images/" . $row['filename'] . "\" alt=\"\" /><br />";
    echo "</p>";
    echo "</div>";
    }


    ?>
     
    MatrixName, Dec 23, 2012 IP
  12. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #12
    That's backwards - unless you have to use double quotes to quote the string, use single quotes. (Then you can use double quotes inside the string, but that's not the reason to quote strings in PHP with single quotes.) If you don't know why you have to use double quotes, don't.
     
    Rukbat, Dec 23, 2012 IP
  13. MatrixName

    MatrixName Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    what have i to add to make the image with size?
     
    MatrixName, Dec 23, 2012 IP
  14. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #14
    Make the image the size you want using a picture editor, and don't tell the browser what size to make it. Different browsers mess graphics up differently when they resize them.
     
    Rukbat, Dec 23, 2012 IP
  15. MatrixName

    MatrixName Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    i mean here echo "<img src=\"images/" . $row['filename'] . "\" alt=\"\" /><br />";

    Can you add a size tagg or something else for example
    echo "<img src=\"images/" . $row['filename'] . "\" height="400" widht="400" alt=\"\" /><br />";
    But that don't work :S
     
    MatrixName, Dec 23, 2012 IP
  16. Altometa

    Altometa Member

    Messages:
    12
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    33
    Digital Goods:
    1
    #16
    Make it

    echo '<img src="images/"' . $row['filename'] . '\" height="400" widht="400" alt="\" /><br />';

    In the part after $row['filename'], you closed the quote here "\", that's why it won't work. Using single quotation IMO is better since you don't get confuse as much as you use double quotation.
     
    Altometa, Jun 24, 2018 IP