The error message "unterminated string literal" is returned when the MySQL output data is assigned to the JS variable.

Source: Internet
Author: User

Read a text data from MySQL and pay it to JS variables such

CopyCodeThe Code is as follows: <SCRIPT type = "text/JavaScript"> var STRs = "surun grape plantation relies on two major transportation corridors: huining Expressway and yangxiao expressway, which are close to Xue Cun, Shangdang town, zhenrong Road, only 20 kilometers away from Zhenjiang City, the transportation is convenient. New varieties are introduced in surun grape plantation,

New processes, new technologies, and modern management systems are planted in greenhouses. Currently, there are five main varieties:,, huangmi, and golden finger. Surun grape plantation also ...";

Document. Write (STRs); </SCRIPT>

However, Firefox always reports the unterminated string literal error. Copy the text to the TXT file and several black blocks are displayed. It turns out to be the MySQL line feed mark \ r \ n. In the TXT file, it cannot be correctly displayed due to dual-byte usage, therefore, two black boxes are displayed.

Solution: Remove \ r \ n when the server returns this data.

$ Value = str_replace ("\ r \ n", "", $ value)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.