Help with Slideshow

I am getting a syntax error on this code. Can anyone help me? The error happens around line 60.

On this line:

<?php echo getJSRandomized($path_to_images, $image_list, $num_to_rotate); ?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<script src="" type="text/javascript"></script>
<script src="" type="text/javascript"></script>

$path_to_images = "";  // path to your images 
$num_to_rotate = "ALL"; // number or "ALL" (to rotate all images in directory) 

// returns string to echo into JavaScript images array  
function getJSRandomized($path, $list, $num) { 
    $str = '"'; 
    mt_srand( (double)microtime() * 1000000 ); 
    if ( $num == "ALL" ) $num = count($list); 
    for ($i=0; $i<$num; $i++) { 
        $str .= $path . $list[$i] . '", "'; 
    // remove last comma and space 
    $str = substr($str, 0, -3); 
    return $str; 

function getImagesList($path) { 
    $ctr = 0; 
    if ( $img_dir = @opendir($path) ) { 
        while ( false !== ($img_file = readdir($img_dir)) ) { 
            // add checks for other image file types here, if you like 
            if ( preg_match("/(.GIF|.jpg)$/", $img_file) ) { 
                $images[$ctr] = $img_file; 
        return $images; 
    } else { 
        return false; 

<body onload="dw_Rotator.start()">
<?php if ( $image_list = getImagesList($path_to_images) ) : ?>

<script type="text/javascript">
    This code is from Dynamic Web Coding at
    Copyright 2001-5 by Sharon Paine 
    See Terms of Use at
    regarding conditions under which you may use this code.
    This notice must be retained in the code as is!
    See full source code at
var imgList = [
  <?php echo getJSRandomized($path_to_images, $image_list, $num_to_rotate);  ?>
var rotator1 = new dw_RandRotator(4000); // rotation speed
// images array, width and height of images, transition filter (boolean)
rotator1.setUpImage(imgList, 251, 188, true);

<?php else : ?>
<!-- image to display if directory listing fails -->
<img src="" width="252" height="127" alt="">

<script type="text/javascript">dw_Rotator.start = function() {};</script>

<?php endif; ?>


What’s the exact error code?

I am getting the following Error with this code:
Internet Explorer Script Error
An error has occured in the script on this page
Line: 60
Char: 3
Error: Syntax Error
Code: 0

Thanks for your help.

That’s not a PHP error :wink:
Not sure if it’s a JavaScript error though (looks like it). Check out line 60 of the output HTML.

This is what is at line 60 it’s some PHP code:

<?php echo getJSRandomized($path_to_images, $image_list, $num_to_rotate); ?>

It’s sandwiched in between some Javascript:
var imgList = [

<?php echo getJSRandomized($path_to_images, $image_list, $num_to_rotate); ?>


For some reason it doesn’t like it. Anyone have a suggestion?

Well yes, I didn’t ask for the source PHP, but the output HTML :wink:

I have posted the code here (click ok to get past the license:

Thanks for your help.

Ah, now I see the problem: your PHP is not being parsed.
Change the extension of your file to .php.

That removes the error but the pictures don’t rotate.
Here is the new file -

Any help would be appreciated. Thanks.

I’m thinking your problem is in the file dw_rotator.js.

We’re not a JavaScript helpdesk though, and I think you should be able to debug this one by yourself as well, if you wrote it yourself (and if you didn’t, please consult the author of the script).

Sponsor our Newsletter | Privacy Policy | Terms of Service