Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
how to get mysql end of lines inside javascript variable?

mysql table - text column - has this content

lorem ipsum
lorem ipsum

I fetch this content as php story variable - and need now to create a javascript variable

var story = "<?php echo $story; ?>";

console says:
Uncaught SyntaxError: Invalid or unexpected token

if I change table content to lorem ipsum lorem ipsum - it works fine

so obvioysly the problem is with mysql new line characters

I tried - $story = str_replace(PHP_EOL, "\n", $story); - before echoing in javascript - but the same result

how to solve this ?

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!