Hi,
The code below is a Jquery News Ticker. It works but recently the codes broke. The codes are pulling data from the database. Some of the titles and descriptions have ' or "" in them. Would that stop the codes from working? If so, if you dont mind, Please explain to me what I need to do to fix this issue. Thanks in advance.
It is also giving me an "unterminated string literal" error message in FireBug. But i'm not sure how to debug the issue.
<script type="text/javascript">
$(document).ready(function(){
var newsArray =
[<?php $username = "******"; $password = "******"; $hostname = "localhost"; $database = "******"; $db_events = mysql_connect($hostname, $username, $password); mysql_select_db($database, $db_events); $current_date = date('Y-m-d H:i:s'); $boardpull = mysql_query("SELECT * FROM events WHERE end_time >= '$current_date'"); $i = 1; $rows = mysql_num_rows($boardpull); while($b = mysql_fetch_assoc($boardpull)){ ?>'<p><strong class="evt-title"><?php echo $b['title']; ?></strong><br /><?php echo $b['day']; ?>, <?php echo $b['date'].' @ '.$b['time']; ?> <br /><strong>More Details:</strong><?php echo $b['description']; ?></p>'<?php if($i < $rows) { echo ', '; } $i++; } mysql_close($db_events);?>];
// set variables here
var newsLength = newsArray.length;
var newsInterval = 5000;
$('.list-events').after('<ul id="news-feed"></ul>');
// add the items in the array to a list
for(i=0; i < newsLength; i++){
$('#news-feed').append('<li>'+newsArray[i]+'</li>');
}
function slideArticle() {
$('#news-feed li:last').clone().prependTo('#news-feed').css('display','none');
$('#news-feed li:first').fadeIn(1000, function(){
$(this).delay(1000).slideDown('fast');
});
$('#news-feed li:last').fadeOut().remove();
}
setInterval(slideArticle, newsInterval);
});
</script>