Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

213
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda