Log in

View Full Version : DB driven JS slideshow problem



sickstick
04-12-2008, 09:08 PM
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

thetestingsite
04-12-2008, 11:51 PM
Try this for your php 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.

sickstick
04-13-2008, 12:01 AM
that still didn't fix it, but it did put in the breaks.

thx

thetestingsite
04-13-2008, 12:01 AM
Please post a link to the problem page so that I can see exactly what it is doing.

sickstick
04-13-2008, 07:15 AM
hey, i don't have it live, im testing it off of WAMP, can I send you an email of the files?

thetestingsite
04-13-2008, 03:09 PM
Sure, I'll be happy to take a look for you.

sickstick
04-13-2008, 06:09 PM
I sent it to your testingsite.net email account.

thetestingsite
04-13-2008, 07:11 PM
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.

sickstick
04-13-2008, 07:34 PM
thank you so much!!! your a lifesaver, i just couldn't figure it out!

- Adam

lachojr
11-07-2008, 09:08 PM
Would you please post the source code??

I have the same problem!!!! :confused: