MyBB Community Forums

Full Version: [Tutorial] Basic Site-Forum Integration
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7
I hope this thread isnt too old...

On the forum statistics everything works except for the Registered users stat, it just displays 13 but not "13 users"...

Code:
<?php
$host = "localhost"; // Your database host
$user = ""; // Your database username
$pass = ""; // Your database password
$data = ""; // The name of your database
$prfx = ""; // The table prefix of your database

$conn = mysql_connect($host,$user,$pass) or die ("<b>Error:</b> Database connection failed.");
$sel = mysql_select_db($data,$conn) or die("<b>Error:</b> Database connection failed.");
$topic_result = mysql_query("SELECT COUNT(*) as count FROM ".$prfx."threads");
$topic_count = mysql_fetch_array($topic_result);
$topic_count = $topic_count["count"];
$post_result = mysql_query("SELECT COUNT(*) as count FROM ".$prfx."posts");
$post_count = mysql_fetch_array($post_result);
$post_count = $post_count["count"];
$user_result = mysql_query("SELECT COUNT(*) as count FROM ".$prfx."users");
$user_count = mysql_fetch_array($user_result);
$user_count = $user_count["count"];
$forum_result = mysql_query("SELECT COUNT(*) as count FROM ".$prfx."forums");
$forum_count = mysql_fetch_array($forum_result);
$forum_count = $forum_count["count"];
?>
<table>
 <tr>
  <td><b><?php echo $topic_count; ?></b></td>
  <td>Threads</td>
 </tr>
 <tr>
  <td><b><?php echo $post_count; ?></b></td>
  <td>Posts</td>
 </tr>
 <tr>
  <td><b><?php echo $user_count; ?></b></td>
 </tr>
 <tr>
  <td><b><?php echo $forum_count; ?></b></td>
  <td>Forums</td>
 </tr>
</table> 
Does the recent posts work on 1.1.x?

I keep getting the error:
Warning: chdir(): No such file or directory (errno 2) in URL HERE

The forums are in forums/ and its configered as the rest.
I keep getting that same error too. This is from older versions, It needs an update for it to work in 1.2.3/4


I got it work by adding
define("IN_MYBB", 1);


below the require thing And by deleting chdir($rel);
The guy above me solved my problem. If you have some problem with direct init. or make sure in_mybb is defined do what he said. Thanks a lot.

Anyone know how to do a log out script? I dont remember. Ill probably figure it out.
i can give you a log out script. PM me
Thankyou for this topic. I love the login script. I'll definitely be using it. It makes the website look a lot more professional and integrates nicely with the forum. Lovely.
Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined.

i get that message when i use it
Add

define("IN_MYBB", 1);
at the beginning of the file.
hi guys...
I'd like to insert the last posts titles in a web page but I have not understood how...
Can u please explain me?
Thanks!!
Pages: 1 2 3 4 5 6 7