سؤال

I have data (MySQL) with html tag which I want to display on nicEditor, but it alway errors :

unterminated string literal

The following code breaks on the line nicE.setContent(...

Javascript code:

<script>
    var nicE = new nicEditors.findEditor('txtfulldes');
    nicE.setContent('<?php echo $datafrommysql?>');
</script>

Data is in MySQL

It has br, bold and more html tags

  • and miscellaneous charges, as well as acceptance of interview without
  • any prerequisites by the interviewing company/party could be a scam.
  • It is also illegal for the interviewing company/party to detain the

Best regards

هل كانت مفيدة؟

المحلول

probably text $datafrommysql have new lines like

something<br/>
something<br/> 
something

which break js.

it should be instead

something<br/>something<br/>something

in one line.

if that's the case and you have <br/> tags in it for new lines try clear \r and \n:

nicE.setContent('<?php echo str_replace(array("\r", "\n"), array("", ""),$datafrommysql)?>');
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top