2021-01-13, 09:29 PM
I want to show posts from a specific forum on a regular php page from my website. I tried to use the code from the last post this topic: https://community.mybb.com/thread-210775.html with mediocre results.
While the posts get shown correctly like
Post Title
Post Content
Posted by: username
I end up with getting these errors displayed on the same page just before the posts:
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
This is the code I put in the first row of the file /test/showcontent.php
And this code is inserted in the same document at the place where the posts should be shown
The error.log shows this:
I assume customboardprefix_ is self explanatory to the people with enough knowledge to help me out on this one.
Really looking forward to get this fixed since mybb is such a nice board compared to phpbb. I'm impressed.
Thank you for your time, I really appreciate everybody who is trying to help me
While the posts get shown correctly like
Post Title
Post Content
Posted by: username
I end up with getting these errors displayed on the same page just before the posts:
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
This is the code I put in the first row of the file /test/showcontent.php
<?php
chdir("./../forum/"); // path to MyBB
define("IN_MYBB", 1);
require_once("./global.php");
global $mybb, $db, $cache, $lang, $plugins; // Trim this list of global vars, if you want to.
?>
And this code is inserted in the same document at the place where the posts should be shown
<?php
$query = $db->query("
SELECT t.tid, t.fid, t.uid, t.username, t.subject, t.replies, t.views, t.lastposter, p.message
FROM ".customboardprefix_."threads t
INNER JOIN ".customboardprefix_."posts p ON (p.tid=t.tid)
WHERE t.fid='2' AND t.visible='1'
ORDER BY t.dateline DESC
LIMIT 6"
);
$list = '';
while($fetch = $db->fetch_array($query))
{
$list .= "<strong><a href=\"forum/showthread.php?tid={$fetch['tid']}\">".htmlspecialchars_uni($fetch['subject'])."</a></strong><br />";
$list .= "".htmlspecialchars_uni($fetch['message'])."<br>";
$poster = "<a href=\"forum/member.php?action=profile&uid=".$fetch['uid']."\">{$fetch['username']}</a>";
$list .= "Posted by: {$poster}<br /><br />";
}
//output
echo $list;
?>
The error.log shows this:
<error>
<dateline>1610572442</dateline>
<script>inc/functions.php</script>
<line>4820</line>
<type>2</type>
<friendly_type>Warning</friendly_type>
<message>Cannot modify header information - headers already sent by (output started at /www/htdocs/root_id/mydomain.com/test/showdocument.php:1)</message>
<back_trace>#0 errorHandler->error() called at [[PHP]: ]
#1 header() called at [/inc/functions.php:4820]
#2 send_page_headers() called at [/global.php:37]
#3 require_once() called at [/www/htdocs/root_id/mydomain.com/test/showdocument.php:29]
</back_trace>
</error>
<error>
<dateline>1610572442</dateline>
<script>inc/functions.php</script>
<line>2063</line>
<type>2</type>
<friendly_type>Warning</friendly_type>
<message>Cannot modify header information - headers already sent by (output started at /www/htdocs/root_id/mydomain.com/test/showdocument.php:1)</message>
<back_trace>#0 errorHandler->error() called at [[PHP]: ]
#1 header() called at [/inc/functions.php:2063]
#2 my_setcookie() called at [/inc/class_session.php:380]
#3 session->load_guest() called at [/inc/class_session.php:113]
#4 session->init() called at [/global.php:49]
#5 require_once() called at [/www/htdocs/root_id/mydomain.com/test/showdocument.php:29]
</back_trace>
</error>
<error>
<dateline>1610572442</dateline>
<script>inc/functions.php</script>
<line>2063</line>
<type>2</type>
<friendly_type>Warning</friendly_type>
<message>Cannot modify header information - headers already sent by (output started at /www/htdocs/root_id/mydomain.com/test/showdocument.php:1)</message>
<back_trace>#0 errorHandler->error() called at [[PHP]: ]
#1 header() called at [/inc/functions.php:2063]
#2 my_setcookie() called at [/inc/class_session.php:385]
#3 session->load_guest() called at [/inc/class_session.php:113]
#4 session->init() called at [/global.php:49]
#5 require_once() called at [/www/htdocs/root_id/mydomain.com/test/showdocument.php:29]
</back_trace>
</error>
<error>
<dateline>1610572442</dateline>
<script>inc/functions.php</script>
<line>2063</line>
<type>2</type>
<friendly_type>Warning</friendly_type>
<message>Cannot modify header information - headers already sent by (output started at /www/htdocs/root_id/mydomain.com/test/showdocument.php:1)</message>
<back_trace>#0 errorHandler->error() called at [[PHP]: ]
#1 header() called at [/inc/functions.php:2063]
#2 my_setcookie() called at [/inc/class_session.php:120]
#3 session->init() called at [/global.php:49]
#4 require_once() called at [/www/htdocs/root_id/mydomain.com/test/showdocument.php:29]
</back_trace>
</error>
<error>
<dateline>1610572442</dateline>
<script>/www/htdocs/root_id/mydomain.com/test/showdocument.php</script>
<line>37</line>
<type>2</type>
<friendly_type>Warning</friendly_type>
<message>Use of undefined constant customboardprefix_ - assumed 'customboardprefix_' (this will throw an Error in a future version of PHP)</message>
<back_trace>#0 errorHandler->error() called at [/www/htdocs/root_id/mydomain.com/test/showdocument.php:37]
</back_trace>
</error>
<error>
<dateline>1610572442</dateline>
<script>/www/htdocs/root_id/mydomain.com/test/showdocument.php</script>
<line>38</line>
<type>2</type>
<friendly_type>Warning</friendly_type>
<message>Use of undefined constant customboardprefix_ - assumed 'customboardprefix_' (this will throw an Error in a future version of PHP)</message>
<back_trace>#0 errorHandler->error() called at [/www/htdocs/root_id/mydomain.com/test/showdocument.php:38]
</back_trace>
</error>
I assume customboardprefix_ is self explanatory to the people with enough knowledge to help me out on this one.
Really looking forward to get this fixed since mybb is such a nice board compared to phpbb. I'm impressed.
Thank you for your time, I really appreciate everybody who is trying to help me