Page 1 of 1

PHP web gallery from BetterPHP.co.uk

Posted: Mon Dec 05, 2011 1:34 pm
by Josh7Harington
Hey guys,
I am new to PHP but have a good understanding of coding as I have done other languages for about a year now.

I did the PHP web gallery tutorial on : http://betterphp.co.uk/playlist.html?pi ... 2BCB69CCEC

But it wont work for me. It wont create a thumbnail folder or do anything on the page besides give me this:
$thumb_aspect){ // wider $new_size = array(($thumb_width / $src_size[1]) * $src_size[0],$thumb_height); $src_pos = array(($new_size[0] - $thumb_width) * ($src_size[0] / $new_size[0])) / 2, 0); }else{ // same shape $new_size = array($thumb_width, $thumb_height); $src_pos = array(0, 0); } if ($new_size[0] < 1){$new_size[0] = 1; if ($new_size{1} , 1) $new_size[1] = 1; $thumb = imagecreatetruecolor($thumb_width, $thumb_height); imagecopyresampled($thumb, $src, 0, 0, $src_pos[0], $src_pos[1], $new_size[0], $new_size[1], $src_size [0], $src_size[1]); if ($src_size['mime'} === 'image/jpeg'){ imagejpeg($thumb, "thumbs/{$_GET['img']"); }else if ($src_size['mime'] === 'image/png'){ imagepng($thumb, "thumbs/{$_GET['img']"); }else if ($src_size{'mime'] === 'image/gif'){ imagegif($thumb, "thumbs/{$_GET['img']"); } header("location: thumbs/{@_GET['img']" } die(); if (is_dir('./thumbs') === false){ mkdir('./thumbs', 0744); } $images = glob('*.{jpg,jpeg,png,gif}', GLOB_BRACE); ?>|&{$image}\*"; }else{ echo "|&{$image}\*"; } } ?> 
Please help me out here or will you send me a link to somewhere (tut or something) that could help me write a new one but properly ??

Thanx,
Josh

Re: PHP web gallery from BetterPHP.co.uk

Posted: Mon Dec 05, 2011 1:39 pm
by jacek
Can you post the code in a way that it does not go all on one line ? :?

It's going to be pretty hard to debug like that ;)

Also, do you get any errors ? If the thumbnail generation is failing the error may not be visible but you should see if if you browse to the location of the image which if I remember rightly is somethign like index.php?img=file.png

Re: PHP web gallery from BetterPHP.co.uk

Posted: Mon Dec 05, 2011 1:58 pm
by EcazS
If that is the code you're trying to use then no wonder it doesn't work. It's all commented out :lol:!

Re: PHP web gallery from BetterPHP.co.uk

Posted: Mon Dec 05, 2011 2:09 pm
by Josh7Harington
EcazS wrote:If that is the code you're trying to use then no wonder it doesn't work. It's all commented out :lol:!

That is the result that is given when I open the page.

Re: PHP web gallery from BetterPHP.co.uk

Posted: Mon Dec 05, 2011 3:54 pm
by EcazS
If that is what you see when you open the page then your file does not have the .php extension or something is terribly wrong with your server.

Re: PHP web gallery from BetterPHP.co.uk

Posted: Mon Dec 05, 2011 4:02 pm
by Josh7Harington
EcazS wrote:If that is what you see when you open the page then your file does not have the .php extension or something is terribly wrong with your server.

It is a .php extension, I am using localhost. I've done it exactly like the tut.

Re: PHP web gallery from BetterPHP.co.uk

Posted: Mon Dec 05, 2011 4:23 pm
by Temor
post your full code