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

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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