favauth, contains uid (userid) and favuid
Favstory, contains uid and sid (story id)
<?
//Connect to the database, with the right username/password, etc
mysql_connect(localhost, pass, pass) or die("Could not connect to the database");
mysql_select_db("database") or die("Could not select the specified database");
//set up an array to associate with each table
$authors = array();
$stories = array();
$favauth = array();
$Favstory = array();
//setup an array of table names
$tables = array('authors','stories','favauth','Favstory');
//get the uids used in each table
foreach($tables as $cur_table) {
$sql = "SELECT DISTINCT(uid) FROM $table";
$query = mysql_query($sql);
while(($row = mysql_fetch_object($query)) !== FALSE)
$$cur_table[] = $row->uid;
} //end foreach
//create an array of authors that are have no entries in the other tables
$boneBags = array_diff($authors,$stories,$favauth,$Favstory);
$sql = "DELETE FROM authors WHERE uid in (" . implode(',',$boneBags) . ')';
mysql_query($sql);
?>
I didn't set up a test environment on my server so this untested and probably needs debugging.