1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Adding image to PHP tag

Discussion in 'Web Design & Development' started by BlackFrancis, Dec 30, 2012.

Thread Status:
Not open for further replies.
Advertisement
  1. BlackFrancis

    BlackFrancis Thread Starter

    Joined:
    Oct 21, 2006
    Messages:
    223
    I've tried to find a tutorial to help me with this, I can't seem to get this to work with simply adding the image with basic HTML nor the following:

    PHP:
    <img src="<?php echo img('image.jpg'); ?>" />
    What I'm working with is this:

    PHP:
    <?php
    global $user_login;
    get_currentuserinfo();
    if(!empty(
    $user_login)){
    echo 
    "<a href='http://egress.ws/members/".$user_login."/profile/edit/group/1/'>Edit Profile</a>";
    }
    ?>
    To clarify: I'd like to replace the linked text above with an image. The normal routine of entering an image into a link doesn't go with this php command.

    Thank you
     
  2. colinsp

    colinsp

    Joined:
    Sep 5, 2007
    Messages:
    2,254
    First Name:
    Colin
    Give this a try

    Code:
     <?php
    global $user_login;
    get_currentuserinfo();
    if(!empty($user_login)){
    echo "<a href='http://egress.ws/members/".$user_login."/profile/edit/group/1/'><img src='img.jpg'></a>";
    }
    ?>
    
     
  3. BlackFrancis

    BlackFrancis Thread Starter

    Joined:
    Oct 21, 2006
    Messages:
    223
    Okay, I'm going to take a wild guess that the " character was the offending article.

    It works. Thank you.
     
  4. JiminSA

    JiminSA

    Joined:
    Dec 15, 2011
    Messages:
    3,323
    First Name:
    Jim
    Your guess is not quite right - Colin was showing you that you hadn't specified an <img> tag to point to an image, your html was simply rendering the text "Edit Profile" as the clickable link... Your single and double quote handling was perfectly correct.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1083045

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice