crawlerbasher Posted January 9, 2010 Share Posted January 9, 2010 I'm having a problem with a custom built function and keep getting this error: Warning: Missing argument 1 for BB_Code::BB_Code(), called in /home/cra10002/public_html/mooglebook/input.php on line 21 and defined in /home/cra10002/public_html/mooglebook/function.php on line 4 Fatal error: Call to undefined method BB_Code::parse() in /home/cra10002/public_html/mooglebook/input.php on line 22 the fuction code is this: <?php function BB_Code($text) { $text = " " . $text; if (! (strpos($text, "[") && strpos($text, "]")) ) { return $text; } else { $text = preg_replace("/\\[b\\](.+?)\[\/b\]/is",'<b>\1</b>', $text); $text = preg_replace("/\\[i\\](.+?)\[\/i\]/is",'<i>\1</i>', $text); $text = preg_replace("/\\[u\\](.+?)\[\/u\]/is",'<u>\1</u>', $text); $text = preg_replace("/\[s\](.+?)\[\/s\]/is",'<s>\1</s>', $text); $text = preg_replace("/\\[sub\\](.+?)\[\/sub\]/is",'<sub>\1</sub>', $text); $text = preg_replace("/\\[sup\\](.+?)\[\/sup\]/is",'<sup>\1</sup>', $text); $text = preg_replace("/\\[tt\\](.+?)\[\/tt\]/is",'<tt>\1</tt>', $text); $text = eregi_replace("\\[img]([^\\[]*)\\[/img\\]","<img src=\"\\1\">",$text); $text = eregi_replace("\\[size([^\\[]*)\\]([^\\[]*)\\[/size\\]","<font size=\"\\1px\">\\2</font>",$text); $text = eregi_replace("\\[font([^\\[]*)\\]([^\\[]*)\\[/font\\]","<font face=\"\\1\">\\2</font>",$text); $text = eregi_replace("\\[color=([^\\[]*)\\]([^\\[]*)\\[/color\\]","<font color=\"\\1\">\\2</font>",$text); $text = eregi_replace("\\[align=([^\\[]*)\\]([^\\[]*)\\[/align\\]","<div align=\"\\1\">\\2</div>",$text); $text = eregi_replace("\\[email=([^\\[]*)\\]([^\\[]*)\\[/email\\]","<a href=\"mailto:=\"\\1\">\\2</a>",$text); $text = eregi_replace("\\[email=([^\\[]*)\\]([^\\[]*)\\[/email\\]","<a href=\"\\1\">\\2</a>",$text); return $text; } } ?> and this is the part of the other code thats causing the problem, this script works fine before this line was posted and an attmpt to make bb code to html tag. $parse_text = BB_Code($comment); If anyone can help me around this problem I would be greatful Thank you Crawlerbasher Link to comment https://forums.phpfreaks.com/topic/187878-bb_code-error/ Share on other sites More sharing options...
JAY6390 Posted January 9, 2010 Share Posted January 9, 2010 http://www.php.net/manual/en/ref.bbcode.php Why not just use the bb code functions already made? Link to comment https://forums.phpfreaks.com/topic/187878-bb_code-error/#findComment-991945 Share on other sites More sharing options...
crawlerbasher Posted January 9, 2010 Author Share Posted January 9, 2010 because I want restrctions on what kind of bb code can be used. The last thing I want is some one posting naked pictures of celebs on the guest book. Link to comment https://forums.phpfreaks.com/topic/187878-bb_code-error/#findComment-991948 Share on other sites More sharing options...
JAY6390 Posted January 9, 2010 Share Posted January 9, 2010 You define which tags can be used to begin with, so you can do that Link to comment https://forums.phpfreaks.com/topic/187878-bb_code-error/#findComment-991952 Share on other sites More sharing options...
crawlerbasher Posted January 9, 2010 Author Share Posted January 9, 2010 I'm looking at that right now. I've copy and pasted it as on the link, but come up with this error. Fatal error: Call to undefined function bbcode_create() in /home/cra10002/public_html/mooglebook/function.php on line 31 I'm looking at the code and can't see what could be causing this error. Could this error be caused by an php thats not up todate? Link to comment https://forums.phpfreaks.com/topic/187878-bb_code-error/#findComment-991958 Share on other sites More sharing options...
JAY6390 Posted January 9, 2010 Share Posted January 9, 2010 Yep. You should run phpinfo(); and see what version you are running Link to comment https://forums.phpfreaks.com/topic/187878-bb_code-error/#findComment-991962 Share on other sites More sharing options...
crawlerbasher Posted January 9, 2010 Author Share Posted January 9, 2010 PHP Version 5.2.9 If this dose not work due to php version. Any idea on solving the original problem? Link to comment https://forums.phpfreaks.com/topic/187878-bb_code-error/#findComment-991972 Share on other sites More sharing options...
JAY6390 Posted January 9, 2010 Share Posted January 9, 2010 It could just be that the module isn't installed. Is this on a local machine or a remote host? Link to comment https://forums.phpfreaks.com/topic/187878-bb_code-error/#findComment-991993 Share on other sites More sharing options...
redarrow Posted January 10, 2010 Share Posted January 10, 2010 try this every think works properly. <?php $text="[b]redarrow[/b][i]says it[/i][sup]working properly[/sup]"; function BB_Code($text) { $text = " " . $text; if (! (strpos($text, "[") && strpos($text, "]")) ) { return $text; } else { $text = preg_replace("/\\[b\\](.+?)\[\/b\]/is",'<b>\1</b>', $text); $text = preg_replace("/\\[i\\](.+?)\[\/i\]/is",'<i>\1</i>', $text); $text = preg_replace("/\\[u\\](.+?)\[\/u\]/is",'<u>\1</u>', $text); $text = preg_replace("/\[s\](.+?)\[\/s\]/is",'<s>\1</s>', $text); $text = preg_replace("/\\[sub\\](.+?)\[\/sub\]/is",'<sub>\1</sub>', $text); $text = preg_replace("/\\[sup\\](.+?)\[\/sup\]/is",'<sup>\1</sup>', $text); $text = preg_replace("/\\[tt\\](.+?)\[\/tt\]/is",'<tt>\1</tt>', $text); $text = eregi_replace("\\[img]([^\\[]*)\\[/img\\]","<img src=\"\\1\">",$text); $text = eregi_replace("\\[size([^\\[]*)\\]([^\\[]*)\\[/size\\]","<font size=\"\\1px\">\\2</font>",$text); $text = eregi_replace("\\[font([^\\[]*)\\]([^\\[]*)\\[/font\\]","<font face=\"\\1\">\\2</font>",$text); $text = eregi_replace("\\[color=([^\\[]*)\\]([^\\[]*)\\[/color\\]","<font color=\"\\1\">\\2</font>",$text); $text = eregi_replace("\\[align=([^\\[]*)\\]([^\\[]*)\\[/align\\]","<div align=\"\\1\">\\2</div>",$text); $text = eregi_replace("\\[email=([^\\[]*)\\]([^\\[]*)\\[/email\\]","<a href=\"mailto:=\"\\1\">\\2</a>",$text); $text = eregi_replace("\\[email=([^\\[]*)\\]([^\\[]*)\\[/email\\]","<a href=\"\\1\">\\2</a>",$text); return $text; } } echo BB_Code($text); ?> Link to comment https://forums.phpfreaks.com/topic/187878-bb_code-error/#findComment-992139 Share on other sites More sharing options...
crawlerbasher Posted January 11, 2010 Author Share Posted January 11, 2010 with regard to the bb code in php, it dose seem that my host dose not have it supported. And thank you for your help, I've manage to solve it yestaday. Wanted to say that yestaday but had problems trying to login. Thank you again everyone for your help. Link to comment https://forums.phpfreaks.com/topic/187878-bb_code-error/#findComment-992534 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.