title: Passing variable with double quotes to javascript
body: <p>In my controller, I have a string coming from database. I use </p>
  
  <pre><code>$user_id = $this-&gt;input-&gt;post('user_id');
  
  $this-&gt;load-&gt;model('database','', TRUE);
  
  $projects = $this-&gt;database-&gt;get_projects($user_id);
  
      foreach($projects as $project)
      {
  
          echo '  &lt;div onclick="someFunction(\''.$project['description'].'\')"&gt;&lt;/div&gt;';
      }
  </code></pre>
  
  <p>to pass value to a Javascript. 
  Everything works fine, unless there's a double quote in the string. Firebug throws </p>
  
  <blockquote>
    <p>unterminated string literal</p>
  </blockquote>
  
  <p>I've tried:</p>
  
  <pre><code>onclick = "someFunction(\''.addslashes($project['description']).'\')"
  </code></pre>
  
  <p>or</p>
  
  <pre><code>$description = str_replace('"', '&amp;quot;', $project['description']);
  onclick = "someFunction(\''.$description.'\')";
  </code></pre>
  
  <p>but it didn't work. </p>
  
  <p>Thanks for your help</p>