Gubbins Posted April 10, 2009 Share Posted April 10, 2009 I have a file were all my bb codes are for my forum and the url part has never worked, i have this:- $txt = str_replace("[url]", "<url>", $txt); $txt = str_replace("[/url]", "</url>", $txt); all it does is show the address but its not clickable. Can anyone help please Regards Gubbins Link to comment https://forums.phpfreaks.com/topic/153483-solved-url-links-not-working/ Share on other sites More sharing options...
ToonMariner Posted April 10, 2009 Share Posted April 10, 2009 $txt = str_replace("(.)*?", "<a href="$1">$1</a>", $txt); Link to comment https://forums.phpfreaks.com/topic/153483-solved-url-links-not-working/#findComment-806397 Share on other sites More sharing options...
Gubbins Posted April 10, 2009 Author Share Posted April 10, 2009 $txt = str_replace("(.)*?", "<a href="$1">$1</a>", $txt); Thank you but when i tried i got this error:- Parse error: syntax error, unexpected '$' in Link to comment https://forums.phpfreaks.com/topic/153483-solved-url-links-not-working/#findComment-806404 Share on other sites More sharing options...
ToonMariner Posted April 10, 2009 Share Posted April 10, 2009 my bad... try this <?php $txt = preg_replace('/[url](.)*?[/url]', '<a href="$1">$1</a>', $txt); ?> Link to comment https://forums.phpfreaks.com/topic/153483-solved-url-links-not-working/#findComment-806406 Share on other sites More sharing options...
Gubbins Posted April 10, 2009 Author Share Posted April 10, 2009 my bad... try this <?php $txt = preg_replace('/[url](.)*?[/url]', '<a href="$1">$1</a>', $txt); ?> Thanks again but now i have a very different error that does not show the url link:- Warning: preg_replace() [function.preg-replace]: Unknown modifier 'r' in ...... Link to comment https://forums.phpfreaks.com/topic/153483-solved-url-links-not-working/#findComment-806415 Share on other sites More sharing options...
ToonMariner Posted April 10, 2009 Share Posted April 10, 2009 me again - must slow down today... $txt = preg_replace('/\[url\](.)*?\[\/url\]/', '<a href="$1">$1</a>', $txt); Link to comment https://forums.phpfreaks.com/topic/153483-solved-url-links-not-working/#findComment-806438 Share on other sites More sharing options...
Gubbins Posted April 10, 2009 Author Share Posted April 10, 2009 me again - must slow down today... $txt = preg_replace('/\[url\](.)*?\[\/url\]/', '<a href="$1">$1</a>', $txt); Thanks again, Well i think we are almost there, i now have the last letter of the url showing so if it was www.google.com the m of the com would be showing and i can click on it. but when you hover your mouse over the url the address shown at the bottom is www.yoursite.com/forum/m. What do you think it could be? Link to comment https://forums.phpfreaks.com/topic/153483-solved-url-links-not-working/#findComment-806451 Share on other sites More sharing options...
ToonMariner Posted April 10, 2009 Share Posted April 10, 2009 lol my regex crapness once more!!!! $txt = preg_replace('/\[url\](.*)?\[\/url\]/', '<a href="$1">$1</a>', $txt); see if that works - i'm not on form today - sorry. Link to comment https://forums.phpfreaks.com/topic/153483-solved-url-links-not-working/#findComment-806462 Share on other sites More sharing options...
Gubbins Posted April 10, 2009 Author Share Posted April 10, 2009 lol my regex crapness once more!!!! $txt = preg_replace('/\[url\](.*)?\[\/url\]/', '<a href="$1">$1</a>', $txt); see if that works - i'm not on form today - sorry. That worked a treat THANK YOU. Is there now away i can get it to open in a new window outside of my forum? Link to comment https://forums.phpfreaks.com/topic/153483-solved-url-links-not-working/#findComment-806467 Share on other sites More sharing options...
Gubbins Posted April 10, 2009 Author Share Posted April 10, 2009 I am guessing its something like:- onclick="window.open(this.href, '_blank', 'width=500,height=700,scrollbars=yes,resizable=no,status=no,screenx=5,screeny=5');return false;" onkeypress="this.onclick()" But how i incorporate that into the url bb code god knows lol Link to comment https://forums.phpfreaks.com/topic/153483-solved-url-links-not-working/#findComment-806509 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.