Jump to content

bbcode problem


ColdEdge

Recommended Posts

Hey, I am trying to use BBCode on my site like

[img=.....][url=google]google.co.jp[/url][b]...[/b][i]...[/i]:smile::angel:[quote=ColdEdge]....[/quote]and thats about it

My current code dose not run for some reason

function parse($quote_main) {$patternu = "\[url\](.*)\[/url\]\[title\](.*)\[/title\]";$replacementu = "<a href=\"\\1\" target=\"_blank\">\\2</a>";$quote_main = ereg_replace($patternu, $replacementu, $quote_main);$patterni = "\[img\](.*)\[/img\]";$replacementi = "<br><img src=\"\\1\" width=\"150px\" style=\"border:2px solid #c3d9ff;padding:3px;\"><br><a href=\"\\1\">Download Image</a>";$quote_main = ereg_replace($patterni, $replacementi, $quote_main);$pattern = ":\)";$replacement = "<img src=\"/images/emoticon_smile.png\" style=\"border:none;\">";$quote_main = ereg_replace($pattern, $replacement, $quote_main);$pattern = ":O";$replacement = "<img src=\"/images/emoticon_surprised.png\" style=\"border:none;\">";$quote_main = ereg_replace($pattern, $replacement, $quote_main);$pattern = ";\)";$replacement = "<img src=\"/images/emoticon_wink.png\" style=\"border:none;\">";$quote_main = ereg_replace($pattern, $replacement, $quote_main);$pattern = ":\(";$replacement = "<img src=\"/images/emoticon_unhappy.png\" style=\"border:none;\">";$quote_main = ereg_replace($pattern, $replacement, $quote_main);$pattern = ":D";$replacement = "<img src=\"/images/emoticon_grin.png\" style=\"border:none;\">";$quote_main = ereg_replace($pattern, $replacement, $quote_main);$pattern = ":P";$replacement = "<img src=\"/images/emoticon_tongue.png\" style=\"border:none;\">";$quote_main = ereg_replace($pattern, $replacement, $quote_main);$pattern = "";$replacement = "<img src=\"/images/emoticon_happy.png\" style=\"border:none;\">";$quote_main = ereg_replace($pattern, $replacement, $quote_main);return $quote_main;}

What am I doing wrong?

Link to comment
Share on other sites

Have you tried running it with the highest error reporting level on (E_ALL | E_NOTICE)? It clears all the technical bugs. If you still have problems after that, you're doing something wrong in the rest of your program. Also, ereg is deprecated, so you should try and get used to preg instead.

Link to comment
Share on other sites

by using something like [*/img] tags the PHP dose not convert it to <img src.... blabla bla... /> but displays it as bbcode tag + img link
If that's the case then I would guess that it's not matching on one or both of the tags. Is your image ending tag really "[*/img]", or was that a typo? If it's not a typo then you'll need to take into account that the "*" character has a special meaning in regexp.Also, as someone else mentioned, the ereg() is deprecated. You should definitely not be developing code using it, as it will all have to be re-written for use on more recent versions of PHP. Here's a fairly good BB Code converter that might save you a lot of time: http://psoug.org/snippet/Convert_BBCode_Tags_35.htm
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...