Part of my script is a simple add record script, it works fine normally, but when I put in inside a function, it'll submit the record, confirm, and tell me it's successfuly, but when I look at it in PHPMyAdmin, a new row was made, but none of the variables were submitted, only the automatic ones, like Primary Key and Timestamp, here's the code:

// this function adds an item to the db
function add_record()
	// we're adding a new record
	$sql = mysql_query ("INSERT INTO items (title, blah1, blah2) 
	VALUES ('$title', '$blah1', '$blah2')") or die (mysql_error());

	// run SQL against the DB to confirm
	$result = mysql_query($sql);
	echo "<p>Record updated/edited!</p>";

// if the Add Record button was pushed
if ($add_record)

	// connect to MySQL database
	$dbcnx = mysql_connect($site, $username, $password) or die (mysql_error());
	mysql_select_db($dbName, $dbcnx);


	} // end of form submition
The script runs fine, if the instructions inside the function add_record() was inside the "if ($add_record)", but I have no idea why it will not submit variables once it's inside the function(), I even get the message "Record updated/edited!"