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>

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

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.