title: Creating a javascript alert with php that has a php variable inside?
body: <p>I'm making a form that is supposed to create a javascript alert when some fields aren't filled out or filled out properly. <em>I want to be able to take the error messages I've put in a php variable and display them in the javascript alert window</em>. </p>
  
  <p>The following code does not work:</p>
  
  <pre><code>function died($error) {
      echo '&lt;script type="text/javascript"&gt; alert('.$error.')&lt;/script&gt;';
      die();
  }
  </code></pre>
  
  <p>How can I add the string contained in <code>$error</code> between the two <em>"script" strings</em> so it will output properly as a javascript alert?</p>
  
  <p>Thank you!</p>