Unexpected $end

Hi.

I’m making a plugin for the forum software, MyBB, but I’m having a small issue. There seems to be an unexpected $end (?> on the last line) but I don’t understand why? Any help would be great.

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();
	}
?>

Thank you.

unexpected $end means you missed closing something somewhere.

Look closer at your definition for fawn… specifically the innermost IF.

Ah thank you, I realized I’ve missed out a } for closing the function. Thanks for pointing that out. I didn’t realize that an unexpected $end was meaning that there is an unclosed function or array etc. I’m new to PHP. Thank you :slight_smile: