What exactly are you trying to do. It looks like there are a few syntax errors in your code. I would probably do something like,
Code:
<?php // common.php
function error($msg) {
print<<<ERRORMSG
<html>
<head>
<script language="JavaScript">
<!--
alert('$msg');
history.back();
//-->
</script>
</head>
<body>
</body>
</html>
ERRORMSG;
exit;
}
?>