MyBB Community Forums

Full Version: Plugin error
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
MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's a status for your users','1212','textarea','0','300','no','yes','no')' at line 3
Query:
INSERT INTO mybb_mybb_profilefields (name,description,disporder,type,length,maxlength,required,editable,hidden) VALUES ('Custom Status','Add's a status for your users','1212','textarea','0','300','no','yes','no')
It's important to escape your strings that are going into the database. Not only for accidents like this but also to prevent SQL injections. You can use $db->escape_string() for this:
 $profilefield = array(
        "name" => $db->escape_string("Custom Status"),
        "description" => $db->escape_string("Add's a status for your users"),
        "disporder" => '1212',
        "type" => "textarea" 
        "lenth" => '0'
        "maxlength" => '300',
        "required" => "no",
        "editable" => "yes",
        "hidden" => "no",
);

In this it isn't really necessary but it's a good practice to do it. Especially when inputting user inputed data into the database.
That made a error here.
syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/gfxcafen/public_html/test/inc/plugins/status.php on line 39

"lenth" => '0'
You also need to have comma after that line too.
(2011-05-04, 11:38 PM)Aries-Belgium Wrote: [ -> ]You also need to have comma after that line too.
I did, thinking that was the issue and nothing changed.

(2011-05-04, 10:27 PM)Aries-Belgium Wrote: [ -> ]You need to include the function file before using the function
include MYBB_ROOT."/inc/adminfunctions_templates.php";

You should use require_once() instead of include.



As for the templates problem, you can totally eliminate it by doing it as a variable append as I said before. Especially with the information that Tom posted about variables in the templates.
As said, it would be better to just append it to the variable. Also, shouldn't the lenth be length?
So I would have to add a hook right? This hook?
$plugins->add_hook("postbit", "What here?");

And after the hook what?

Still a error after fixing the length here is my code.
<?php

// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

function status_info()
{
global $db;

	return array(
		'name'			=> 'Allow user to make their own status',
		'description'	=> 'Users edit there profile, enter a status and it will appear in the postbit',
		'website'		=> 'http://mods.mybb.com/',
		'author'		=> 'Blake',
		'authorsite'	=> 'http://mcmines.com',
		'version'		=> '1.0',
		'compatibility'	=> '16*',
	);
}

function status_activate()
{

global $db;

require MYBB_ROOT."/inc/adminfunctions_templates.php"; 

find_replace_templatesets("postbit", "#".preg_quote("{\$post['onlinestatus']}")."#i", "{\$post['onlinestatus']} <br /><strong>{\$post['fid1212']}</strong>");   

//Adds a Custome Profile Field
    $profilefield = array(
        "name" => $db->escape_string("Custom Status"),
        "description" => $db->escape_string("Add's a status for your users"),
        "disporder" => '1212',
        "type" => "textarea" 
        "length" => '0',
        "maxlength" => '300',
        "required" => "no",
        "editable" => "yes",
        "hidden" => "no",
		$db->insert_query(TABLE_PREFIX."profilefields", $profilefield);
		$fid = $db->insert_id();
		$fieldname = "fid$fid";
		$db->query("ALTER TABLE ".TABLE_PREFIX."userfields ADD $fieldname TEXT;");
		$db->query("OPTIMIZE TABLE ".TABLE_PREFIX."userfields");

}

function status_deactivate()
{

require MYBB_ROOT."/inc/adminfunctions_templates.php"; 

 find_replace_templatesets("postbit", "#".preg_quote("<br /><strong>{$post['fid1212']}</strong>")."#i", '', 0); 

//Remove Status Field
   global $db;
	
	$db->query("DELETE FROM ".TABLE_PREFIX."profilefields WHERE name='Custom Status'");
}

?>
You still have no comma on the line before length.
Toungue

Parse error: syntax error, unexpected ';', expecting ')' in /home/gfxcafen/public_html/test/inc/plugins/status.php on line 44

$db->insert_query(TABLE_PREFIX."profilefields", $profilefield);
Pages: 1 2 3 4 5 6