SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2011
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    echo not working - what am I doing wrong?

    I am trying to echo the following:

    PHP Code:
    echo "<td>" "<img src=\"" $_SERVER['DOCUMENT_ROOT'] . "/uploads/" $file_base_name "\"" "alt=\"" $row2['filename'] . "\"" "/>" "</td>"
    Which should display an image in the table cell. I can confirm that the variables $file_base_name and $row_table2['filename'] are filled -- I've echoed each independently and got the desired results.

    The above code produces:
    Code:
    <td><img src="example.com/uploads/" alt="" /></td>
    Variables after $_SERVER['DOCUMENT_ROOT'] are not being interpreted, and I don't know why.

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,047
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    Sounds like those variables do not exist in the scope. Did you dump the variables in the same exact file and get the proper results or was it a different file?
    The only code I hate more than my own is everyone else's.

  3. #3
    SitePoint Zealot
    Join Date
    Nov 2011
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I did more testing, and it turns out server['document_root'] was giving me problems by outputting the absolute path, including c:\. Thanks for the attempted help though.


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
  •