I\'m making a form that is supposed to create a javascript alert when some fields aren\'t filled out or filled out properly. I want to be able to take the error messages I\'
You only forgot quotations that are required for the JavaScript alert.
If you passed 'hello' to the function, your current code would create alert as:
alert(hello)
instead of doing:
alert("hello")
Therefore, change your line to the following (two double quotes are added before and after concatenating $error):
echo '';
and you can use your function:
died('error on whatever');