yoda87 Posted May 11, 2011 Share Posted May 11, 2011 Hi all, i've set this script for my gallery, it works, it display me the name of the albums, but when i click to see the pictures inside, the page is blank, and also don't appear the "Back to the albums" link, i can't find the error in the code... <html> <head> <script type="text/javascript" src="../lightbox2.05/js/lightbox.js"> </script> </head> <body> <?php $page = $_SERVER['PHP_SELF']; //settings $column = 5; //directories $base = "carrelli_noleggio"; $thumbs = "thumbs"; // get album $get_album = $_GET['album']; //if no album selected if (!$get_album) { echo "<b>Select an album:</b><p />"; //find each album and display as links $handle = opendir($base); while (($file = readdir($handle))!==FALSE) { if (is_dir($base."/".$file) && $file != "." && $file != ".." && $file != $thumbs) { echo "<a href='$page?album=$file'>$file</a><br />"; } } closedir($handle); } else { //check if album exist, and additional security checks if (!is_dir($base."/".$get_album) || strstr($get_album,".") !=NULL || strstr($get_album,"/") !=NULL || strstr($get_album,"\") !=NULL) { echo "Album doesn't exist."; } else { $x = 0; echo "<b>$get_album</b><p />"; $handle = opendir($base."/".$get_album); while (($file = readdir($handle)) !== FALSE) { if ($file != "." && $file != "..") { echo "<table style='display:inline;'><tr><td><a href='$base/$get_album/$files' ref='lightbox'<img src='$base/$thumbs/$file' height='100' width'100'></a></td></tr></table>"; $x++; if ($x==$column) { echo"<br />"; $x = 0; } } } closedir($handle); echo "<p /><a href='$page>Back to albums</a>"; } } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/236088-php-script-photo-gallery-help/ Share on other sites More sharing options...
PHPete Posted May 11, 2011 Share Posted May 11, 2011 From what I can see I think you've gone wrong with the quotes. The colour shows that most of that is a string rather than the code. Quote Link to comment https://forums.phpfreaks.com/topic/236088-php-script-photo-gallery-help/#findComment-1213731 Share on other sites More sharing options...
yoda87 Posted May 11, 2011 Author Share Posted May 11, 2011 From what I can see I think you've gone wrong with the quotes. The colour shows that most of that is a string rather than the code. I see, but frist i use doble " and after single ', I do not know how to do otherwise... Quote Link to comment https://forums.phpfreaks.com/topic/236088-php-script-photo-gallery-help/#findComment-1213733 Share on other sites More sharing options...
PHPete Posted May 11, 2011 Share Posted May 11, 2011 strstr($get_album,".") !=NULL The problem seems to be with the quotes in this line, but I'm not sure why. (I could also be completely wrong, this is just what I can see) Quote Link to comment https://forums.phpfreaks.com/topic/236088-php-script-photo-gallery-help/#findComment-1213734 Share on other sites More sharing options...
yoda87 Posted May 11, 2011 Author Share Posted May 11, 2011 here http://php.net/manual/en/function.strstr.php seems to be correct.. Quote Link to comment https://forums.phpfreaks.com/topic/236088-php-script-photo-gallery-help/#findComment-1213738 Share on other sites More sharing options...
harristweed Posted May 11, 2011 Share Posted May 11, 2011 The \ in this line is escaping the quote, you need to add another quote! if (!is_dir($base."/".$get_album) || strstr($get_album,".") !=NULL || strstr($get_album,"/") !=NULL || strstr($get_album,"\") !=NULL) Add quote: if (!is_dir($base."/".$get_album) || strstr($get_album,".") !=NULL || strstr($get_album,"/") !=NULL || strstr($get_album,"\"") !=NULL) Quote Link to comment https://forums.phpfreaks.com/topic/236088-php-script-photo-gallery-help/#findComment-1213740 Share on other sites More sharing options...
PHPete Posted May 11, 2011 Share Posted May 11, 2011 The \ in this line is escaping the quote, you need to add another quote! Ah, I can't believe I missed that. :/ Quote Link to comment https://forums.phpfreaks.com/topic/236088-php-script-photo-gallery-help/#findComment-1213742 Share on other sites More sharing options...
yoda87 Posted May 11, 2011 Author Share Posted May 11, 2011 Ok, here's my mistake, the original code i wrote was ... if (!is_dir($base."/".$get_album) || strstr($get_album,".") !=NULL || strstr($get_album,"/") !=NULL || strstr($get_album,"\\") !=NULL) { with two \\ , anyway there's other error, because don't work Quote Link to comment https://forums.phpfreaks.com/topic/236088-php-script-photo-gallery-help/#findComment-1213749 Share on other sites More sharing options...
PHPete Posted May 11, 2011 Share Posted May 11, 2011 The backslashes escape quotes. Try adding an extra quote if (!is_dir($base."/".$get_album) || strstr($get_album,".") !=NULL || strstr($get_album,"/") !=NULL || strstr($get_album,"\\"") !=NULL) Quote Link to comment https://forums.phpfreaks.com/topic/236088-php-script-photo-gallery-help/#findComment-1213752 Share on other sites More sharing options...
yoda87 Posted May 11, 2011 Author Share Posted May 11, 2011 The backslashes escape quotes. Try adding an extra quote if (!is_dir($base."/".$get_album) || strstr($get_album,".") !=NULL || strstr($get_album,"/") !=NULL || strstr($get_album,"\\"") !=NULL) Dreamweaver sign it as an error Quote Link to comment https://forums.phpfreaks.com/topic/236088-php-script-photo-gallery-help/#findComment-1213753 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.