MyBB Community Forums

Full Version: Getting errors while developing plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
so i started developing mybb plugin.I read some tutorials but when i applied same i get the following errors
Code:
 $aarushi_group = array(
        'gid'    => 'NULL',
        'name'  => 'yourplugin',
        'title'      => 'YourPlugin',
        'description'    => 'Settings For YourPlugin',
        'disporder'    => "1",
        'isdefault'  => 'no',
    );
 $db->insert_query('settinggroups', $aarushi_group);
Error:
( ! ) Fatal error: Call to a member function insert_query() on a non-object in C:\wamp\www\forum\Upload\inc\plugins\aarushi.php on line 34


Code:
$plugins->add_hook("index_start", "deaf");
Error:
( ! ) Fatal error: Call to a member function add_hook() on a non-object in C:\wamp\www\forum\Upload\inc\plugins\aarushi.php on line 27
Add $db as global object. Like this;
global $db;
Thanks,The first error goes away but what about the second error?Still getting

MY CODE:
$plugins->add_hook("index_start", "deaf"); 


ERROR
( ! ) Fatal error: Call to a member function add_hook() on a non-object in C:\wamp\www\forum\Upload\inc\plugins\aarushi.php on line 28
What function are using to run your hook? If you only post snippets of you code how do you expect anyone to help you ?
i haven't developed function.i am new to developing mybb plugins.just had an echo in the function

 function deaf(){
echo 'aarushi';
}
You didn't add the global $db, $mybb; like yardarm told you to.

function deaf(){
global $db, $mybb;
echo 'aarushi';
} 
(2012-05-16, 09:04 AM)Frank.Barry Wrote: [ -> ]You didn't add the global $db, $mybb; like yardarm told you to.

function deaf(){
global $db, $mybb;
echo 'aarushi';
} 

Here is my full code.Still getting error

<?php
/**
 * Aarushi 1.0
 * Create by Dhruv Jain
 * http://hackarchives.org
 */
 if(!defined("IN_MYBB"))
{
    die("");
} 
global $db,$mybb;
 function deaf(){
echo 'aarushi';
}
function aarushi_info()
{
	return array(
		"name"		=> "Aarushi Plugin",
		"description"		=> "IP hiding of Admin",
		"website"		=> "http://hackarchives.org",
		"author"		=> "Dhruv Jain",
		"authorsite"		=> "http://hackarchives.org",
		"version"		=> "1.0",
		"guid" 			=> "",
		"compatibility"	=> "*"
		);
} 
function aarushi_activate()
  {

$plugins->add_hook("index_start", "deaf"); }
?>



Your all over the place, try this:

<?php
/**
 * Aarushi 1.0
 * Create by Dhruv Jain
 * http://hackarchives.org
 */

 if(!defined("IN_MYBB"))
{
    die("");
} 

function aarushi_info()
{
    return array(
        "name"        => "Aarushi Plugin",
        "description"        => "IP hiding of Admin",
        "website"        => "http://hackarchives.org",
        "author"        => "Dhruv Jain",
        "authorsite"        => "http://hackarchives.org",
        "version"        => "1.0",
        "guid"             => "",
        "compatibility"    => "*"
        );
} 
function aarushi_activate()
  {
  }

$plugins->add_hook("index_start", "deaf"); 

 function deaf() {
global $db,$mybb;

echo 'aarushi';
}
?>