How would you fetch data from database by escaping / ignoring mybb codes.
e.g
+--------+
[ color=red ]hi this is me[/color]
+--------+
How do we fetch data so when echoing only " hi this is me " is echoed
This is probably what you want, providing you are accessing MyBB's files.
...
// What we do here is parse the post using our post parser, then strip the tags from it
$parser_options = array(
'allow_html' => 0,
'allow_mycode' => 0,
'allow_smilies' => 0,
'allow_imgcode' => 0,
'filter_badwords' => 0
);
$post['message'] = strip_tags($parser->parse_message($post['message'], $parser_options));
...
Where
$post would be the array of data you're working with.
This is my code, not working i.e. it is showing all mesages without parsing
<?
$query=mysql_query(" SELECT *
FROM `mybb_posts`
LIMIT 0 , 30");
while($row=mysql_fetch_array($query))
{
$parser_options = array(
'allow_html' => 0,
'allow_mycode' => 0,
'allow_smilies' => 0,
'allow_imgcode' => 0,
'filter_badwords' => 0
);
$message[message]=$row[message];
$message[message]=strip_tags($parser->parse_message($message[message], $parser_options));
$message[message]=substr($message[message],0,86);
echo $message[message].'...';
}
?>
Add the following code before your code runs;
require_once MYBB_ROOT."inc/class_parser.php";
still not working
(2012-09-01, 12:30 PM)Yaldaram Wrote: [ -> ]Add the following code before your code runs;
require_once MYBB_ROOT."inc/class_parser.php";
You probably haven't added at proper location. Please paste the entire code your file.
it's in the index template, code is posted above
You're trying to use PHP in the index template? That wont work. MyBB doesnt parse PHP in templates
I have installed php template, I also fetch values from other db, is there any way ?
The PHP in templates plugin doens't really allow PHP; it allows certain functions, and in a slightly different syntax. You'll need to use a plugin for what you want.