Using Double-Quotation Marks In A URL
Solution 1:
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 RFC3986 which defines the safe, or 'unreserved' character as follows:
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
urlencode makes sure that a value you want to include in a URL obeys these standards
Solution 2:
Make sure you urlencode your URL parameter values. see urlencode
Solution 3:
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
Solution 4:
. urlencode($row['title']) . '"> etc
Solution 5:
In my case, urlencode did not help, I used urlencode ($var)
and the result in the browser is:
localhost/"aaMoldau+-+Aus+dem+Zyklus++"Mein+Vaterland""/
What the browser says:
An Error Was Encountered
The URI you submitted has disallowed characters.
And here is my MYSQL entry ($var):
aaMoldau - Aus dem Zyklus "Mein Vaterland"
update:
the quotes in the beginning and end of $var are clear, because I inserted them, but still the error is there.
(I do not understand why urlencode creates double quotes in the beginning and in the end.)
Furthermore, the double quote before 'Mein' and after Vaterland should be removed ?
Update 2:
I now used
str_replace
to remove the double quotes together with urlencode and it is fine. But I thought I did not need str_replace ?
Furthermore, I read another post of stack where it is recommended to change my allowed uri chars to: $config['permitted_uri_chars'] = '+=\a-z 0-9~%.:_-';
Here CodeIgnite was the problem but now solved. Strange that CI does not accept +
in principal which is needed in spaces .
Post a Comment for "Using Double-Quotation Marks In A URL"