I have a problem with a very simple UBB script. First an example of something that already works:
$text = preg_replace("/<a href='search.php?show=bodysearch&term=(.*)'>(.*)<\/a>/Uis", "[search=\\1]", $text);
When somebody posts a certain search link, then its convert to
"/\[search=(.*)\]/Uis",
And that is convert to
"<a href='search.php?show=bodysearch&term=\\1'>Search: \\1</a>",
Example: Search: searchterm
Works fine 🙂
Now i want to add an extra UBB tag simulair to this one
$text = preg_replace("/<a href='topic.php?id=(.*)'>(.*)<\/a>/Uis", "[topic=\\1]", $text);
So when somebody posts a link to a topic on the forum it is convert to:
"/\[topic=([0-9]{0,5})\]/Uis",
And that is convert to
"topicid2topictitle('\\1')",
The function topicid2topictitle is:
function topicid2topictitle($id)
{
global $sql;
if($content = $sql->single_var($sql->query("SELECT title FROM topic WHERE topic='$id'"), 'title'))
$content = "<a href='topic.php?id=$id' target='_blank'>" . stripslashes($content) . "</a>";
else
$content = "<a href='topic.php?id=$id' target='_blank'>[topictitle not found]</a>";
return $content;
}
So when somebody posts http://www.asite.nl/topic.php?id=1 , it should become This is the title of thetopic.
But it does not work. The function topicid2topictitle($id) , works because
[topic=1]
works fine and you get:
This is the title of the topic with a link to the topic
Only when you type http://www.asite.nl/topic.php?id=1 , it is NOT convert to
This is the title of the topic
Can somebody tell me whats going wrong?