Results 1 to 10 of 10

Thread: DB driven JS slideshow problem

  1. #1
    Join Date
    Mar 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default DB driven JS slideshow problem

    Hey guys, im working on a database driven slide show and having a problem, the images in the slideshow aren't showing up. They show up when I run it as a static slideshow, and when I paste in my php code it breaks. I have no idea whats wrong with it. Here's the code of the identical working file, and the broken file.

    - this is the code in the page.
    var fadeimages=new Array()
    <?php
    $counter =0;
    $slide = mysql_query("SELECT * FROM tbl_images");
    while($row=mysql_fetch_array($slide)) {
    echo "fadeimages[".$counter."] = 'images/".$row['img_photo']."';";
    $counter++;
    }
    ?>

    - this is what the php prints on the page in the view source
    var fadeimages=new Array()
    fadeimages[0] = 'images/image1.jpg';fadeimages[1] = 'images/image2.jpg';fadeimages[2] = 'images/image3.jpg';

    -the static code
    var fadeimages=new Array()
    fadeimages[0]="images/image1.jpg"
    fadeimages[1]="images/image2.jpg"
    fadeimages[2]="images/image3.jpg"

    - this is what the static working code prints
    var fadeimages=new Array()
    fadeimages[0]="images/slideshow/image1.jpg"
    fadeimages[1]="images/slideshow/image2.jpg"
    fadeimages[2]="images/slideshow/image3.jpg"

    I don't get any error's or anything with my php. and I have gone through everything i could think of, its probably a small mistake that im not picking up on.

    thx in advance

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Try this for your php code:

    Code:
    <?php
    $counter =0;
    $slide = mysql_query("SELECT * FROM tbl_images");
    while($row=mysql_fetch_array($slide)) {
    echo "fadeimages[".$counter."] = 'images/".$row['img_photo']."'; \r\n";
    $counter++;
    }
    ?>
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Mar 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    that still didn't fix it, but it did put in the breaks.

    thx

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Please post a link to the problem page so that I can see exactly what it is doing.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #5
    Join Date
    Mar 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hey, i don't have it live, im testing it off of WAMP, can I send you an email of the files?

  6. #6
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Sure, I'll be happy to take a look for you.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  7. #7
    Join Date
    Mar 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I sent it to your testingsite.net email account.

  8. #8
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Ok, got it to work (as you can see here: http://thetestingsite.net/test/dd/nsd/slideshow1.php ). The issue was not with the php coding, but instead with an issue with one of the lines in the js code (the code was being wrapped on multiple lines in a document.write() line and it was causing the script to fail). You can download the working source by going to http://thetestingsite.net/test/dd/nsd/slideshow1.phps

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  9. #9
    Join Date
    Mar 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thank you so much!!! your a lifesaver, i just couldn't figure it out!

    - Adam

  10. #10
    Join Date
    Nov 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default please post sourcecode

    Would you please post the source code??

    I have the same problem!!!!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •