2

I am trying to display a URL stored in mysql as a link in php table like this

echo "<td><a href=".$row['resume'].">Resume</a></td>";

where $row['resume'] retrieves correct data using mysql_fetch_array

However the whitespace between file link gets truncated automatically

for example my file name is "this is a resume.doc" i only get "this" in link

help.

2
  • 1
    Can you post the output of var_dump($row['resume']);? Commented Oct 10, 2011 at 20:29
  • var dump gives "this is a resume.doc" Commented Oct 10, 2011 at 20:32

2 Answers 2

6

You need to place quotes around your href attribute.

echo "<td><a href=\"".$row['resume']."\">Resume</a></td>";
Sign up to request clarification or add additional context in comments.

Comments

4

You need to do several things:

  1. Escape characters with special meaning in URLs using urlencode
  2. Escape characters with special meaning in HTML using htmlspecialchars
  3. Quote attribute values

Such:

$url = htmlspecialchars( urlencode( $row['resume'] ) );
echo "<td><a href='$url'>Resume</a></td>";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.