MyBB Community Forums

Full Version: Unexpected $end
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey.

I'm working on a plugin, but I'm having a small issue. There seems to be an unexpected $end on line 70 (the ?> on the last line) but I don't understand why?

Here's my code:

<?php
/**
*	File Warning System 0.1a
*	© 2010 Jordan Lovelle
*	http://mybbrunway.com
*	You may not redistribute this plugin.
*	You are free to modify it how you wish.
*/
if(!defined("IN_MYBB"))
	{
		die("You can't access this file directly. Make sure it's in MyBB.");
	}
// All hooks must go here.
$plugins->add_hook("global_start", "fawn");
function fawn_info()
	{
		return array(
			"name" => "Fawn",
			"description" => "The File Warning System for MyBB Admins.",
			"website" => "http://mybbrunway.com",
			"author" => "Jordan Lovelle",
			"authorsite" => "http://mybbrunway.com/member.php?action=profile&uid=1",
			"version" => "0.1a",
			"guid" => "",
			"compatibility" => "16"
		);
	}
function fawn_activate()
	{
		global $db;
		$fawn_group = array(
			'gid' => 'NULL',
			'name' => 'fawn',
			'title' => 'Fawn - The File Warning System',
			'description' => 'Settings for Fawn, the File Warning System for MyBB Admins.',
			'disporder' => '9001',
			'isdefault' => 'no',
		);
			$db->insert_query('settinggroups', $fawn_group);
			$gid = $db->insert_id();
		$fawn_setting = array(
			'sid' => 'NULL',
			'name' => 'enable_fawn',
			'title' => 'Enable Fawn',
			'description' => 'Selecting yes will enable fawn.',
			'optionscode' => 'yesno',
			'value' => '',
			'disporder' => 1,
			'gid' => 'intval($gid)',
		);
			$db->insert_query('settings', $fawn_setting);
			rebuild_settings();
	}
function fawn()
	{
		global $mybb, $db, $templates;
		if ($mybb->settings['enable_fawn'] == 1)
		{
			if($mybb->user['uid'] == "1"){
				echo("Hi there, Jordan!");
		}
	}
function fawn_deactivate()
	{
		global $db;
		$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN ('enable_fawn')");
		$db->query("DELETE FROM".TABLE_PREFIX."settinggroups WHERE name='fawn'");
		rebuild_settings();
	}
?>

Cheers.
It is because you forgot to close this IF statement :

//...
            if($mybb->user['uid'] == "1"){
                echo("Hi there, Jordan!");
            } // <--- This is missing!
//...
Ah, thank you. Can't believe I missed that. I'm having one other issue now, there's a problem for some reason and it's not inserting the settings in to the database, although it inserts the group. With the code in the OP, is there any reason you see why it might be doing so? Thanks.
Because you placed the function inside apostrophes when it should not :

            'gid' => 'intval($gid)',
Should be :
            'gid' => intval($gid),
Ah brilliant, I didn't realize that either. Thanks for the help Smile
Was a pleasure... Wink