0

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>
2
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by programmer12
0

I would have spaced the Javascript out but in javascript you cant space out the codes or it breaks

0

yes it would.
check for the >>line<< and >>source<< of the "error code" and go get that string corrected.
p.s.: you don't even need the error console to tell you where to look, because its the file and the line of code you or someone else added or modified just before this error ocurred.

0

Thanks! But I already figured it out yesterday.

The problem was the var newsArray = was on another line I had to make the data for that array to appear on the same line, but I fixed it.

-programmer12

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.