claffin Posted March 16, 2009 Share Posted March 16, 2009 Im trying to create a slideshow for my gallery i have the following code config.php <? $total = 4; //Total number of images in slideshow $var_total = 5; //Total number of images + 1 $arr_img = Array(); $handle = opendir('../gallery/'); while (false !== ($file = readdir($handle))) { if ($file != "." & & $file != "..") { $arr_img[] = $file; } } $i = 1; $next = 2; $back = 0; while($i <= $total){ if($back == 0) { $back_link = $total; } else { $back_link = $back; } if($next == $var_total) { $next_link = 1; } else { $next_link = $next; } if ($image == "$i") { $next_img = "$next_link"; $back_img = "$back_link"; } $i++; $next++; $back++; }?> and in gallery.php I have <? require_once "config.php"; if($_REQUEST[auto] == "on") { $meta = "<meta http-equiv="refresh" content="2;url=$PHP_SELF?image=$next_img&auto=on" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />"; $nav = "<a href="$PHP_SELF?image=$back_img&auto=on">Back</a> | <a href="$PHP_SELF?image=$image&auto=off">Stop Slideshow</a> | <a href="$PHP_SELF?image=$next_img&auto=on">Next</a>"; } if($_REQUEST[auto] == "off" || !$_REQUEST[auto]) { $meta = " <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />"; $nav = "<a href="$PHP_SELF?image=$back_img&auto=off">Back</a> | <a href="$PHP_SELF?image=$image&auto=on">Start Slideshow</a> | <a href="$PHP_SELF?image=$next_img&auto=off">Next</a>"; } if(!$_REQUEST[image]) { //Default thumbnil page $i = 0; foreach($arr_img as $var_img) { //Grabs all the image names in th array if($var_img != "") { //Dont show first entery of the array that is blank echo<<<EOF <a href="$PHP_SELF?image=$i"><img src="../gallery/$var_img" /></a> EOF; } $i++; } } else { //Show the slides echo<<<EOF <div align="center"> <img src="./gallery/$arr_img[$image]" /><br /><br /> $nav </div> EOF; } ?> I found this code online as I am unsure of how to do a slideshow the results can be found at http://handweaving.seitservices.com.au/index.php?p=gallery Quote Link to comment Share on other sites More sharing options...
friedemann_bach Posted March 16, 2009 Share Posted March 16, 2009 Get rid of the encapsulated quotation marks in gallery.php (use single quotation marks, then doubles within) and see if it works better ... Quote Link to comment Share on other sites More sharing options...
claffin Posted March 16, 2009 Author Share Posted March 16, 2009 got rid of all the " and replaced with ' <? require_once 'config.php'; if($_REQUEST[auto] == 'on') { $meta = '<meta http-equiv='refresh' content='2;url=$PHP_SELF?image=$next_img&auto=on' /> <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />'; $nav = '<a href='$PHP_SELF?image=$back_img&auto=on'>Back</a> | <a href='$PHP_SELF?image=$image&auto=off'>Stop Slideshow</a> | <a href='$PHP_SELF?image=$next_img&auto=on'>Next</a>"; } if($_REQUEST[auto] == 'off' || !$_REQUEST[auto]) { $meta = ' <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />'; $nav = '<a href='$PHP_SELF?image=$back_img&auto=off'>Back</a> | <a href='$PHP_SELF?image=$image&auto=on'>Start Slideshow</a> | <a href='$PHP_SELF?image=$next_img&auto=off'>Next</a>'; } if(!$_REQUEST[image]) { //Default thumbnil page $i = 0; foreach($arr_img as $var_img) { //Grabs all the image names in th array if($var_img != '') { //Dont show first entery of the array that is blank echo<<<EOF <a href='$PHP_SELF?image=$i'><img src='../gallery/$var_img' /></a> EOF; } $i++; } } else { //Show the slides echo<<<EOF <div align='center'> <img src='./gallery/$arr_img[$image]' /><br /><br /> $nav </div> EOF; } ?> no change still error in line 4 Quote Link to comment Share on other sites More sharing options...
friedemann_bach Posted March 16, 2009 Share Posted March 16, 2009 Ok. But I did not mean replacing all quotes. You cannot have quotes of the same type nested. So you can't have "abc"def"ghi", but either "abc'def'ghi" or 'abc"def"ghi'. Got it? And then, if you use variables (it seems you do) you would need double quotes on the outside, and all quotes within would have to be be preceded by a backslash. So your quotes should look like "abc\"def\"ghi". If you don't need variables, you can prefer 'abc"def"ghi'. But don't mix it up. Now go and try! Quote Link to comment Share on other sites More sharing options...
claffin Posted March 16, 2009 Author Share Posted March 16, 2009 how does this look <? require_once "config.php"; if($_REQUEST[auto] == "on") { $meta = "<meta http-equiv=\"refresh\" content=\"2;url=$PHP_SELF?image=$next_img&auto=on" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />"; $nav = "<a href=\"$PHP_SELF?image=$back_img&auto=on">Back</a> | <a href="$PHP_SELF?image=$image&auto=off">Stop Slideshow</a> | <a href="$PHP_SELF?image=$next_img&auto=on">Next</a>"; } if($_REQUEST[auto] == "off" || !$_REQUEST[auto]) { $meta = " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1" />"; $nav = "<a href=\"$PHP_SELF?image=$back_img&auto=off">Back</a> | <a href="$PHP_SELF?image=$image&auto=on">Start Slideshow</a> | <a href="$PHP_SELF?image=$next_img&auto=off">Next</a>"; } if(!$_REQUEST[image]) { //Default thumbnil page $i = 0; foreach($arr_img as $var_img) { //Grabs all the image names in th array if($var_img != "") { //Dont show first entery of the array that is blank echo<<<EOF <a href="$PHP_SELF?image=$i"><img src="../gallery/$var_img" /></a> EOF; } $i++; } } else { //Show the slides echo<<<EOF <div align="center"> <img src="./gallery/$arr_img[$image]" /><br /><br /> $nav </div> EOF; } ?> Quote Link to comment Share on other sites More sharing options...
friedemann_bach Posted March 17, 2009 Share Posted March 17, 2009 Generally it's a good start You need to do this for every line. But please do not ask me to check every single quotation mark for you You need to do this on your own. I can only tell you the rule how it works. If it does not work, check the error message and check for correct quotes in the corresponding line. Now off to coding work! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.