title: How can I insert a Variable from PHP into a Java Script Variable with a direct variable?
body: <p>How can I put a variable value from PHP $name, into a Java script variable, so I can insert it into this offline openDatabase for testing.  </p>
  
  <pre><code>&lt;?php
  $dbh = new PDO('mysql:host=localhost;dbname=app', 'user' , 'password');
  $stmt = $dbh-&gt;prepare("insert into registered(msg) values (?)");
  
  $stmt-&gt;bindParam(1, $msg);
  $msg= $_POST["msg1"];
  ?&gt;
  
    &lt;script type="text/javascript"&gt;
       var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
       var msg = $name; //how can I make this a $name php variable?
  
       db.transaction(function (tx) {
          tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');
          tx.executeSql('INSERT INTO LOGS (id, log) VALUES (1, "msg")');//put $name into here from php
          document.querySelector('#status').innerHTML =  msg;
       });
    &lt;/script&gt;
  </code></pre>