Thanks, __FILE__ is exactly what I was looking for.
I have to parse it into the function, but it works.
Just in case anyone else wants to use it. It's great it you empty the log at the same time as you backup the database, this way anytime you(or someone else) messes something up you can just recreate the DB from the backup and your mysql-log.
Code:
<?
function RunMySQL($funcs_query, $funcs_file){
$funcs_mysql_log = fopen("/home/www/beta/logs/mysql.txt", 'a');
if(!fwrite($funcs_mysql_log,
"id - ".$_SESSION['id']."\n"
."page - ".$funcs_file."\n"
.str_replace("\n", " ", $funcs_query)."\n")){
$errs[] = "error reporting mysql log.";
};
fclose($funcs_mysql_log);
$funcs_mysql_rslt = mysql_query($funcs_query);
if(!$funcs_mysql_rslt)
$errs[] = mysql_error();
return $funcs_mysql_rslt;
};
RunMySQL("UPDATE tblUsers SET Uname = 'bob' WHERE id=10",
__FILE__);
?>