Reputation: 827
Problem: External links have our domain name to the front of the link.
In database the following string is stored:
To learn more about Rich Habits <a href=”http://www.externaldomain.com”>click here.</a>
In our PHP File we echo the string as such:
</p><?php echo Author::getAuthorBio( $post->author1 ) ?></p>
The resulting HTML from a browser is as such:
<p>To learn more about Rich Habits <a href=”http://www.externaldomain.com”>click here.</a></p>
But, when clicking on link, the url is: mydomain.com/”http://www.externaldomain.com”
How do I make link correct?
Upvotes: 1
Views: 4734
Reputation: 943134
You are trying to quote the value of the attribute with ”
instead of "
. The ”
is not a valid character for quoting attributes in HTML, so it is being treated as part of the URL.
Since ”http://
is not a valid URL scheme, it is being treated as a relative URL.
Replace the ”
with "
.
Your problem is most likely caused by writing your HTML in something other than a text editor. Word processors have a habit of replacing straight quotes with typographic quotes. This is mistake when dealing with code instead of English.
Upvotes: 4
Reputation: 3085
Your ”
around the href attribute are not double quotes. They are special characters. Replace them with "
and it'll fix it.
Upvotes: 1