Jump to content

[SOLVED] URL links not working


Gubbins

Recommended Posts

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

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 ......

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?

 

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?

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.