How do I avoid text coming from PHP in JavaScript?
I am using jPlayer to display some videos and I am creating a playlist on the fly in a php foreach statement:
var playlistacting =
[
<?php foreach($this->result as $val){?>
{
title: '<?php echo $val->getTitle();?>',
artist: '<?php echo $val->getDes();?>',
poster: "<?php echo $val->getVideoId();?>.jpg",
thumb: "<?php echo $val->getVideoId();?>.jpg",
flv: "<?php echo $val->getVideoId();?>.flv",
},
<?php }?>
];
and $val->getDes()
an example would beI have a one-hour (approximately) solo musical revue called "Manhattan With A Twist". The entire...
I get an error
unterminated string literal
[Break On This Error]
artist: 'I have a one-hour (approximately)solo musical revue called "Manhattan W...
jquery.js (line 2, col 32)
and is at the beginning '
at the beginning of the line.
I can do it: title: "<?php echo htmlspecialchars($val->getTitle());?>",
and I get the same error but with "
instead '
.
I'm not sure what's going on here. Does he complain about '
not running away or what?
Any ideas?
source to share