MyBB Community Forums

Full Version: Plugin Help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I know, I know. It's really creative title, right? Anyways, I usually just add my custom code directly into a file (like member.php in this case). However, to make upgrades easier, I'm turing my code into plugins. However, the code that worked in member.php no longer works in the plugin. Instead, I get this SQL error:
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 '' at line 1
Query:
    UPDATE mybb_users SET registrationParagraph='' WHERE uid= 


Here's the code for the plugin:
<?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.");
}

$plugins->add_hook("member_do_register_end", "regParagraph_run");

function regParagraph_info()
{
	return array(
		"name"			=> "Paragraph to Database",
		"description"	=> "Puts the users registration paragraph into the database.",
		"website"		=> "http://www.thedrp.org/",
		"author"		=> "Nicholas Roge",
		"authorsite"	=> "http://www.thedrp.org/",
		"version"		=> "1.0",
		"guid" 			=> "",
		"compatibility" => "*"
	);
}

function regParagraph_run()
{
	global $db;
	
	$usr=$user_info['uid'];
    $rP=$db->escape_string($mybb->input['regParagraph']);
    $db->query("UPDATE mybb_users SET registrationParagraph='$rP' WHERE uid=$usr");
}
?>

Any ideas?
$db->update_query("users", array('registrationParagraph' =>$rP), "uid='".$usr."'")

If that doesn't work try escaping the $rP variable
No, that doesn't work. However, should the following be the correct function? Although I already tried this)
$db->update_query("users", array('registrationParagraph' =>$rP), "uid=".$usr);
Because $usr is a variable holding an integer. I'm not honestly sure though what you mean by escaping the $rP though.
You need to also add $user_info and $mybb to the global line.
Thank you so much! It works now.