Jump to content

White space?


Doug
Go to solution Solved by Doug,

Recommended Posts

I've been trying to solve this for the past 2 days! Please help.



I get this message while trying to validate the code in W3c valifation service.



bad value %20images/image_name%20 for attribute src on element img: Whitespace in path component. Use %20 in place of spaces.



There is no white space in the lines below. OR is there? I have put %20 in all white spaces that I could find with no effect.

 


if (is_file(MM_UPLOADPATH . $row['picture']) . filesize(MM_UPLOADPATH . $row['picture']) > 0){echo'%20<a href="pictures.php">%20<img src="%20' . MM_UPLOADPATH . $row['picture'] . '%20" alt="sevenoaks latest pic" style="width:75px; maxheight:110px; margin:5px; padding:5px;"></a>';

if (is_file(MM_UPLOADPATH . $row['picture']) . filesize(MM_UPLOADPATH . $row['picture']) > 0){echo'%20<a href="pictures.php">%20<img src="%20' . MM_UPLOADPATH . $row['picture'] . '%20" alt="sevenoaks latest pic" style="width:75px; maxheight:110px; margin:5px; padding:5px;"></a>';

Link to comment
Share on other sites

why are you even surrounding the src value with whitespace at all? Is your path/to/file really " path/to/file " vs. "path/to/file" ? Did you try just doing

 

if (is_file(MM_UPLOADPATH . $row['picture']) . filesize(MM_UPLOADPATH . $row['picture']) > 0){echo'%20<a href="pictures.php">%20<img src="' . MM_UPLOADPATH . $row['picture'] . '" alt="sevenoaks latest pic" style="width:75px; maxheight:110px; margin:5px; padding:5px;"></a>';
Link to comment
Share on other sites

Try building this var and then using in the src:

$src = urlencode(MM_UPLOADPATH . $row['picture']);
echo '<a href="pictures.php"><img src="' . $src . '" alt="sevenoaks latest pic" style="width:75px; maxheight:110px; margin:5px; padding:5px;"></a>';
Link to comment
Share on other sites

urlencode will encode the directory separators (slashes) in MM_UPLOADPATH (and in $row['picture'] if it has any subdirectories). You have to encode each component of the path individually and then piece it back together. Or use the shortcut from AbraCadaver if you are sure you will never have any other special characters.

 

If you know MM_UPLOADPATH is clean, and $row['picture'] will not have subdirectories, you can just encode $row['picture'] before concatenation.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.