phpwiz Posted July 28, 2009 Share Posted July 28, 2009 Ok i have this BBcode script and i get an error script: <?php function bbcode($text){ $arrayBBCode=array( ''=> array('type'=>BBCODE_TYPE_ROOT, 'childs'=>'!i'), 'i'=> array('type'=>BBCODE_TYPE_NOARG, 'open_tag'=>'<i>', 'close_tag'=>'</i>', 'childs'=>'b'), 'url'=> array('type'=>BBCODE_TYPE_OPTARG, 'open_tag'=>'<a href="{PARAM}">', 'close_tag'=>'</a>', 'default_arg'=>'{CONTENT}', 'childs'=>'b,i'), 'img'=> array('type'=>BBCODE_TYPE_NOARG, 'open_tag'=>'<img src="', 'close_tag'=>'" />', 'childs'=>''), 'b'=> array('type'=>BBCODE_TYPE_NOARG, 'open_tag'=>'<b>', 'close_tag'=>'</b>'), 'center'=> array('type'=>BBCODE_TYPE_NOARG, 'open_tag'=>'<center>', 'close_tag'=>'</center>'), 'u'=> array('type'=>BBCODE_TYPE_NOARG, 'open_tag'=>'<u>', 'close_tag'=>'</u>'), 'img'=> array('type'=>BBCODE_TYPE_NOARG, 'open_tag'=>'<img src="', 'close_tag'=>'" border="0">'), ); $BBHandler=bbcode_create($arrayBBCode); $text = bbcode_parse($BBHandler,$text); return $text; } ?> error: Fatal error: Call to undefined function bbcode_create() in /home/www/tpnrpg.awardspace.biz/BBcodes.php on line 24 Quote Link to comment https://forums.phpfreaks.com/topic/167752-easy-stuff/ Share on other sites More sharing options...
Speedy84 Posted July 28, 2009 Share Posted July 28, 2009 tried spaces? $BBHandler = bbcode_create($arrayBBCode); Quote Link to comment https://forums.phpfreaks.com/topic/167752-easy-stuff/#findComment-884611 Share on other sites More sharing options...
phpwiz Posted July 28, 2009 Author Share Posted July 28, 2009 tried spaces? $BBHandler = bbcode_create($arrayBBCode); didnt work Quote Link to comment https://forums.phpfreaks.com/topic/167752-easy-stuff/#findComment-884612 Share on other sites More sharing options...
Philip Posted July 28, 2009 Share Posted July 28, 2009 The error message says it all.... undefined function Quote Link to comment https://forums.phpfreaks.com/topic/167752-easy-stuff/#findComment-884614 Share on other sites More sharing options...
phpwiz Posted July 28, 2009 Author Share Posted July 28, 2009 What is it tho o.o? Quote Link to comment https://forums.phpfreaks.com/topic/167752-easy-stuff/#findComment-884619 Share on other sites More sharing options...
slapdashwebdesigner Posted July 28, 2009 Share Posted July 28, 2009 The error message says it all.... undefined function this is because you must first install the bbcode extension of php but with out it you can achieve a similar out come with <?php function bbcode($string) { while (preg_match_all('`\[(.+?)=?(.*?)\](.+?)\[/\1\]`', $string, $matches)) foreach ($matches[0] as $key => $match) { list($tag, $param, $innertext) = array($matches[1][$key], $matches[2][$key], $matches[3][$key]); switch ($tag) { case 'b': $replacement = "<strong>$innertext</strong>"; break; case 'i': $replacement = "<em>$innertext</em>"; break; case 'size': $replacement = "<span style=\"font-size: $param;\">$innertext</a>"; break; case 'color': $replacement = "<span style=\"color: $param;\">$innertext</a>"; break; case 'center': $replacement = "<div class=\"centered\">$innertext</div>"; break; case 'quote': $replacement = "<blockquote>$innertext</blockquote>" . $param? "<cite>$param</cite>" : ''; break; case 'url': $replacement = '<a href="' . ($param? $param : $innertext) . "\">$innertext</a>"; break; case 'img': list($width, $height) = preg_split('`[Xx]`', $param); $replacement = "<img src=\"$innertext\" " . (is_numeric($width)? "width=\"$width\" " : '') . (is_numeric($height)? "height=\"$height\" " : '') . '/>'; break; case 'video': $videourl = parse_url($innertext); parse_str($videourl['query'], $videoquery); if (strpos($videourl['host'], 'youtube.com') !== FALSE) $replacement = '<embed src="http://www.youtube.com/v/' . $videoquery['v'] . '" type="application/x-shockwave-flash" width="425" height="344"></embed>'; if (strpos($videourl['host'], 'google.com') !== FALSE) $replacement = '<embed src="http://video.google.com/googleplayer.swf?docid=' . $videoquery['docid'] . '" width="400" height="326" type="application/x-shockwave-flash"></embed>'; break; } $string = str_replace($match, $replacement, $content); } return $string; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/167752-easy-stuff/#findComment-884623 Share on other sites More sharing options...
phpwiz Posted July 28, 2009 Author Share Posted July 28, 2009 Didnt work Quote Link to comment https://forums.phpfreaks.com/topic/167752-easy-stuff/#findComment-884632 Share on other sites More sharing options...
slapdashwebdesigner Posted July 28, 2009 Share Posted July 28, 2009 <?php function bbcode($string) { while (preg_match_all('`\[(.+?)=?(.*?)\](.+?)\[/\1\]`', $string, $matches)) foreach ($matches[0] as $key => $match) { list($tag, $param, $innertext) = array($matches[1][$key], $matches[2][$key], $matches[3][$key]); switch ($tag) { case 'b': $replacement = "<strong>$innertext</strong>"; break; case 'i': $replacement = "<em>$innertext</em>"; break; case 'size': $replacement = "<span style=\"font-size: $param;\">$innertext</span>"; break; case 'font': $replacement = "<span style=\"font-family: $param;\">$innertext</span>"; break; case 'color': $replacement = "<span style=\"color: $param;\">$innertext</a>"; break; case 'center': $replacement = "<center>$innertext</center>"; break; case 'quote': $replacement = "<blockquote>$innertext</blockquote>" . $param? "<cite>$param</cite>" : ''; break; case 'url': $replacement = '<a href="' . ($param? $param : $innertext) . "\">$innertext</a>"; break; case 'img': list($width, $height) = preg_split('`[Xx]`', $param); $replacement = "<img src=\"$innertext\" " . (is_numeric($width)? "width=\"$width\" " : '') . (is_numeric($height)? "height=\"$height\" " : '') . '/>'; break; case 'video': $videourl = parse_url($innertext); parse_str($videourl['query'], $videoquery); if (strpos($videourl['host'], 'youtube.com') !== FALSE) $replacement = '<embed src="http://www.youtube.com/v/' . $videoquery['v'] . '" type="application/x-shockwave-flash" width="425" height="344"></embed>'; if (strpos($videourl['host'], 'google.com') !== FALSE) $replacement = '<embed src="http://video.google.com/googleplayer.swf?docid=' . $videoquery['docid'] . '" width="400" height="326" type="application/x-shockwave-flash"></embed>'; break; } $string = str_replace($match, $replacement, $content); } return $string; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/167752-easy-stuff/#findComment-884633 Share on other sites More sharing options...
phpwiz Posted July 28, 2009 Author Share Posted July 28, 2009 On my news http://tpnrpg.awardspace.biz/Current_news.php it shows blank when i inserted data Quote Link to comment https://forums.phpfreaks.com/topic/167752-easy-stuff/#findComment-884638 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.