Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9
This is the forum to discuss the Wrox book PHP and MySQL: Create-Modify-Reuse by Timothy Boronczyk, Martin E. Psinas; ISBN: 9780470192429
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 18th, 2009, 04:14 PM
Authorized User
Points: 374, Level: 6
Points: 374, Level: 6 Points: 374, Level: 6 Points: 374, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2009
Location: San Jose, Californina
Posts: 77
Thanks: 4
Thanked 6 Times in 6 Posts
Default Chap 2 - Avatars and uploading files, (would apply to Chap 6 too)

PROBLEM 1. chapter 2 mistake in the file view.php

In the book at about line 100 there is a mistake.
Code:
      if (file_exists('avatar/' . $row['USERNAME'] . 'jpg')
This is missing the period before jpg
This is also missing a right parenthesis.

The correct way should be
Code:
     if (file_exists('avatar/' . $row['USERNAME'] . '.jpg'))
In the download code the mistake has been corrected.

PROBLEM 2. chapter 2 - upload_avatar.php

I had a problem with $_FILES['avatar']['error'] returning
error number 6 (UPLOAD_ERR_NO_TMP_DIR).
I solved it as follows.

If $_FILES['avatar']['error'] is error number 6,
then you need to go to your php.ini file and set up upload_tmp_dir.
For example, set it to
upload_tmp_dir = /usr/home/myname/www/htdocs/public_files

Also make sure the php.ini file has set
file_uploads = On

When you click the upload button, it will put the file
in that directory.
It gives the file some weird name like phpjpdKfT .
(its a different name every time you click upload)
When the script ends, the file is deleted.

The user's script should copy the file somewhere, and
the JpegThumbnail generator function does just
that. It copies the file to the avatars directory.

The quick deleting of the file makes it a little bit
mysterious because the script runs so fast you can
never see the file in the directory. Just to see it,
and for debugging, I temporarily put a sleep in
there and then I could actually see the file.

The book talks about uploading files in Chapter 2, page 57.
He talks about the uploaded file being temporarily stored and
deleted once the script ends. It was well written and there
is a lot of good information there,
but they did not go into the php.ini part. Since I ran into
this problem, I thought I would post it here.

In chapter 6, the section "Uploading Files", page 161,
the book also has code which checks $_FILES['file']['error']
so the above discussion about the php.ini file would apply
there too.

After I got around these 2 issues I was able to upload
the avatar.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
chap 6, sandeepgreaternoida BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 2 October 31st, 2013 10:05 AM
Chap. 9 - ValidationSummary Ciupaz BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 6 May 28th, 2008 10:58 PM
Chap 1: page33 ed123 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 January 4th, 2008 01:14 PM
Chap 1 Where are the SQL table files? Jim Dean BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 7 July 8th, 2006 02:29 PM
chap 15 manal_sag BOOK: Beginning ASP 3.0 2 July 10th, 2005 04:29 AM



All times are GMT -4. The time now is 01:05 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.