I use a very simple function that i put in an include for javascript errors. Say common.php. Here it is:
<?php // common.php
function error($msg) {
?>
<html>
<head>
<script language="JavaScript">
<!--
alert("<?=$msg?>");
history.back();
//-->
</script>
</head>
<body>
</body>
</html>
<?
echo("$msg");
exit;
}
?>
So whenever you want to trigger a javascript error and at the same time display a text error for those having javascript disabled do this:
include("common.php");
error("Hey, there is an error!");
Have fun 😉