Attempting to get text into a link
Posted: Thu Jul 29, 2010 12:32 pm
I'm lost.. I should also mention that I am a SQL guy thrust into the website, so any help with PHP would be dandy.
I've got this code:
{
$msg = preg_replace("/(https?:\/\/[^\s]+?)([\.,]?[ \s'\"])/","<a href=\"$1\">$1</a>$2", $msg);
$msg = preg_replace('/(www|http:\/\/[^ ]+)/', '<a href="\1">\1</a>', $msg);
$msg = preg_replace("/(www\.[\.\w_-]+[\w]+)([\.,]?[\n\s'\"])/","<a href=\"http://$1\">$1</a>$2", $msg);
$msg = nl2br($msg); return $msg;
}
I'm trying to get text from SQL to relay on the website as a valid URL, and I get the link part to work, but it does a couple things wrong (See Below).
A. It doubles the text/URL
B. When I mouse over the link it shows as a Href and never takes you to the right place.
Here's how it shows on the website:
===============================================================
http://anycompany.net/client-services/register/
Upcoming">http://anycompany.net/client-services/r ... /register/
Upcoming Product Releases
===============================================================
First line won't take me to the actual link.
Second line shouldn't be there! As you can see, line 2 is pulling the word "Upcoming" from the 3rd line below in addition to the URL repeated twice..
Any help would be most appreciated!!
I've got this code:
{
$msg = preg_replace("/(https?:\/\/[^\s]+?)([\.,]?[ \s'\"])/","<a href=\"$1\">$1</a>$2", $msg);
$msg = preg_replace('/(www|http:\/\/[^ ]+)/', '<a href="\1">\1</a>', $msg);
$msg = preg_replace("/(www\.[\.\w_-]+[\w]+)([\.,]?[\n\s'\"])/","<a href=\"http://$1\">$1</a>$2", $msg);
$msg = nl2br($msg); return $msg;
}
I'm trying to get text from SQL to relay on the website as a valid URL, and I get the link part to work, but it does a couple things wrong (See Below).
A. It doubles the text/URL
B. When I mouse over the link it shows as a Href and never takes you to the right place.
Here's how it shows on the website:
===============================================================
http://anycompany.net/client-services/register/
Upcoming">http://anycompany.net/client-services/r ... /register/
Upcoming Product Releases
===============================================================
First line won't take me to the actual link.
Second line shouldn't be there! As you can see, line 2 is pulling the word "Upcoming" from the 3rd line below in addition to the URL repeated twice..
Any help would be most appreciated!!