SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Php echo statement puts a space, don't know why?

    I am using the following statement in a php file:
    PHP Code:
    Echo "<tr><td align=\"right\" bgcolor=\"#e8edff\"> Images:</td>
    <td><a href=files/"
    .$info['general_attachments1'] . ">".$info['general_attachments1'] . "</a></td></tr>"
    For some reason the results come up like the following. Note the space before color.jpg which renders the link unclickable/useable:
    PHP Code:
    <tr><td align="right" bgcolor="#e8edff"Images:</td>
    <
    td><a href=../ color.JPGcolor.JPG</a></td></tr
    Does anybody know what is the problem?

  2. #2
    SitePoint Addict Trent Reimer's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The space is in the $info['general_attachments1'] variable.

  3. #3
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    if you cant find it in the variable you could try using trim()
    PHP Code:
    Echo "<tr><td align=\"right\" bgcolor=\"#e8edff\"> Images:</td> 
    <td><a href=files/"
    .$info['general_attachments1'] . ">".trim($info['general_attachments1']) . "</a></td></tr>"
    this will 'trim' any whitespace from the front and back of the string.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


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
  •