Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

A Hopefully easy little question, MySQL entry and parsing links

Options
  • 26-12-2005 2:39pm
    #1
    Closed Accounts Posts: 4,842 ✭✭✭


    I'm in the process of designing a site and I'm using a phpBB database as my starting blocks (to register for the site you register on the forums, sessions are expanded accross the whole site to allow users to access certain parts if they're logged in, if they have the correct privileges etc and most of the content of the site is pulled from entries admins and mods can post in the forum, i.e. the band can post info on gigs in the gigs forum and it'll be pulled from the database and parsed on the Gigs page of the site)

    My small question is that if a user posts a link on the forum and I'm reparsing it on the page how do I go about making it actually link... I know the obvious solution is to use a str_replace function to change the [ url] tags to <a href tags but this doesn't work if someone uses [ url=something]Here[/ url]

    [php]$query="SELECT u.topic_id, u.forum_id, u.poster_id, u.post_username, w.post_id, w.post_subject, w.post_text, x.username, x.user_id FROM phpbb_posts u, phpbb_posts_text w, phpbb_users x WHERE u.forum_id = 2 AND u.post_id = w.post_id AND w.post_subject != '' AND u.poster_id = x.user_id ORDER BY `post_id` DESC LIMIT 5"; // 2 = forum_id for gigs

    $result = mysql_query($query);
    while($row = mysql_fetch_array($result)) {
    $subject = $row;
    $text = $row;
    $username = $row;
    $id = $row;
    $user_id = $row;

    $text = str_replace("\n","<br />",$text); // add in line breaks

    $text = str_replace(":c1068bc7a3","",$text); // Remove all the poxy bbcode stuff
    $text = str_replace(":b1068bc7a3","",$text);

    $text = str_replace("", "<img src=\"", $text); $text = str_replace("", "\" border=\"0\">", $text);
    $text = str_replace("", "<b>", $text);
    $text = str_replace("
    ", "</b>", $text);
    $text = str_replace("", "<b>", $text);
    $text = str_replace("
    ", "</b>", $text);[/php]

    I'd like to just remove the [ url] tags and make any time http:/ / is mentioned make it link...

    Anyone have any suggestions on how I'd go about doing this?


Comments

Advertisement