tags:

views:

67

answers:

5

Hello,

The link below works fine unless the variable $row["title"] contains a double-quotation mark ("). In that case, everything after the quotation marks is omitted in the link.

How can I make the link include everything after a double-quotation mark?

Thanks in advance,

John

echo '<td class="sitename2"><a href="http://www...com/.../comments/index.php?submission='.$row["title"].'"&gt;'.$row["countComments"].' COMMENTS</a></td>';
+4  A: 

Make sure you urlencode your URL parameter values. see urlencode

Robert Ros
+3  A: 

Always use urlencode for parts of a URL which might need to contain anything unusual....

echo '<td class="sitename2">'.
  '<a href="http://www...com/.../comments/index.php?submission='.
  urlencode($row["title"]).
  '">'.
  $row["countComments"].' COMMENTS</a></td>';

If you want to get into the standards, refer to RFC1738

"...Only alphanumerics [0-9a-zA-Z], the special characters $-_.+!*'(), and reserved characters used for their reserved purposes may be used unencoded within a URL."

urlencode makes sure that a value you want to include in a URL obeys these standards (see the RFC section titled 'URL Character Encoding Issues' for more info)

Paul Dixon
+1 for standards :)
srinivas
A: 

. urlencode($row['title']) . '"> etc

Cups
A: 

DELETED123456567878

myforwik
A: 

Hello,

the values of parameters in a url must be escaped in order for the url to be valid.

so instead of

$row["title"]

use

urlencode($row["title"])

urlencode will transform the double-quote into %22 so you will avoid the problem with the wrong double-quote ending your link.

Jerome Wagner

Jerome WAGNER