PHP web gallery from BetterPHP.co.uk

Ask about a PHP problem here.
Post Reply
Josh7Harington
Posts: 4
Joined: Mon Dec 05, 2011 1:26 pm

PHP web gallery from BetterPHP.co.uk

Post 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
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: PHP web gallery from BetterPHP.co.uk

Post 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
Image
User avatar
EcazS
Posts: 789
Joined: Fri May 06, 2011 5:29 pm

Re: PHP web gallery from BetterPHP.co.uk

Post 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:!
Josh7Harington
Posts: 4
Joined: Mon Dec 05, 2011 1:26 pm

Re: PHP web gallery from BetterPHP.co.uk

Post 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.
User avatar
EcazS
Posts: 789
Joined: Fri May 06, 2011 5:29 pm

Re: PHP web gallery from BetterPHP.co.uk

Post 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.
Josh7Harington
Posts: 4
Joined: Mon Dec 05, 2011 1:26 pm

Re: PHP web gallery from BetterPHP.co.uk

Post 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.
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: PHP web gallery from BetterPHP.co.uk

Post by Temor »

post your full code
Post Reply