| View previous topic :: View next topic |
| Author |
Message |
CaptainPasty
Joined: Sat Aug 28, 2010 11:00 am Posts: 5 Location: Manchester
|
Posted: Sat Aug 28, 2010 11:41 am Post subject: PHP Coding Academy mini-book problems |
|
|
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 |
|
 |
shanita

Joined: Fri Aug 25, 2006 4:20 pm Posts: 9 Location: Belgium
|
Posted: Sun Aug 29, 2010 6:04 pm Post subject: php project 3 blank page |
|
|
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 |
|
 |
CaptainPasty
Joined: Sat Aug 28, 2010 11:00 am Posts: 5 Location: Manchester
|
Posted: Mon Aug 30, 2010 10:27 am Post subject: Post subject: php project 3 blank page |
|
|
| 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 |
|
 |
CaptainPasty
Joined: Sat Aug 28, 2010 11:00 am Posts: 5 Location: Manchester
|
Posted: Mon Aug 30, 2010 10:39 am Post subject: Post subject: php project 3 blank page |
|
|
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 previous topic :: View next topic |
|