Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PHP Coding Academy mini-book problems

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
CaptainPasty



Joined: Sat Aug 28, 2010 11:00 am
Posts: 5
Location: Manchester

PostPosted: Sat Aug 28, 2010 11:41 am    Post subject: PHP Coding Academy mini-book problems Reply with quote

Hi all,

I bought issue 135 of the magazine and (like many people by the sounds of it) found the PHP Coding Academy mini-book that came with it a great little time consumer,but...

By the time I'd gotten to Project 3, page 48 I found myself going around in circles. After saving the code and refreshing the page nothing happens (blank page). I've had a quick look in the "thumbnails" folder and it doesn't seem to be saving them.

Is there a miss-print in the book or (more likely) am I doing something really stupid? I've included my code below so if anyone can help I'd be really grateful:

<?php
$images=scandir("images");
$thumbnails=scandir("thumbnails");

$new_pics=array_diff($images,$thumbnails);

foreach($new_pics as $pic){
//load the original image
$image=imagecreatefromjpeg("images/$pic");

//and save it with %10 quality
imagejpeg($image,"thumbnails/$pic",10);
}

//now loop again, printing out images and links
foreach($images as $image){
//note that we have an <img> inside an <a>
echo"<a href=\"images/$image\"><img
src=\"thumbnails/$image\"/></a>";
}
?>
Back to top
View user's profile Send private message
shanita



Joined: Fri Aug 25, 2006 4:20 pm
Posts: 9
Location: Belgium

PostPosted: Sun Aug 29, 2010 6:04 pm    Post subject: php project 3 blank page Reply with quote

Hi CaptainPasty,

I checked your code (with copy and paste) and it is working perfectly well on my computer.
Maybe you forgot to install php5-gd. This package provides a module for handling graphics directly from php scripts. It supports the png, jpeg, xpm formats.

Good luck
Back to top
View user's profile Send private message
CaptainPasty



Joined: Sat Aug 28, 2010 11:00 am
Posts: 5
Location: Manchester

PostPosted: Mon Aug 30, 2010 10:27 am    Post subject: Post subject: php project 3 blank page Reply with quote

It wouldn't surprise me at all if I've done that! Thanks for your help, Shanita. I'll give it a go...
Back to top
View user's profile Send private message
CaptainPasty



Joined: Sat Aug 28, 2010 11:00 am
Posts: 5
Location: Manchester

PostPosted: Mon Aug 30, 2010 10:39 am    Post subject: Post subject: php project 3 blank page Reply with quote

Just wanted to say thanks. Pulled up Synaptic and php5-gd hadn't been installed. Installed, rebooted and now works fine.

Saved me a lot of headaches!
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast