Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 30th, 2012, 06:11 AM
Authorized User
 
Join Date: May 2011
Posts: 12
Thanks: 0
Thanked 2 Times in 2 Posts
Default Forum: upload avatar

Hi, I am working on the Forum chapter and taken note of the various problems associated with php.ini’s and basedir’s. Everything apparently works OK: the browser searches and uploads a jpeg, a thumbnail is made and stored in the file ‘avatars’, and I think I have set the php.ini and basedir to correctly point to the appropriate files. Nevertheless, I still have some niggling errors. I have a link from a page to ‘upload_avatar’; when it is clicked I get the following warnings detailed below. Note: At this point nothing has been submitted. Then, after I hit the submit button everything behaves as expected and there are no more errors. A Google search has been sufficient to understand what the errors mean, but offers no solution. Any suggestions? because the warnings are choking the ‘errorlog’.
[28-Jan-2012 16:39:12] PHP Notice: Undefined index: avatar in E:\xampp\htdocs\public_files\upload_avatar.php on line 20
[28-Jan-2012 16:39:12] PHP Notice: Undefined index: avatar in E:\xampp\htdocs\public_files\upload_avatar.php on line 24
[28-Jan-2012 16:39:12] PHP Warning: getimagesize() [<a href='function.getimagesize'>function.getimagesize </a>]: Filename cannot be empty in E:\xampp\htdocs\lib\JpegThumbnail.php on line 19
[28-Jan-2012 16:39:12] PHP Warning: Division by zero in E:\xampp\htdocs\lib\JpegThumbnail.php on line 22
[28-Jan-2012 16:39:12] PHP Warning: Division by zero in E:\xampp\htdocs\lib\JpegThumbnail.php on line 22
[28-Jan-2012 16:39:12] PHP Warning: imagecreatefromjpeg() [<a href='function.imagecreatefromjpeg'>function.image createfromjpeg</a>]: Filename cannot be empty in E:\xampp\htdocs\lib\JpegThumbnail.php on line 24
[28-Jan-2012 16:39:12] PHP Warning: imagecreatetruecolor() [<a href='function.imagecreatetruecolor'>function.imag ecreatetruecolor</a>]: Invalid image dimensions in E:\xampp\htdocs\lib\JpegThumbnail.php on line 29
[28-Jan-2012 16:39:12] PHP Warning: imagecopyresized() expects parameter 1 to be resource, boolean given in E:\xampp\htdocs\lib\JpegThumbnail.php on line 31
[28-Jan-2012 16:39:12] PHP Warning: imagedestroy() expects parameter 1 to be resource, boolean given in E:\xampp\htdocs\lib\JpegThumbnail.php on line 32
[28-Jan-2012 16:39:12] PHP Warning: imagejpeg() expects parameter 1 to be resource, boolean given in E:\xampp\htdocs\lib\JpegThumbnail.php on line 43
[28-Jan-2012 16:39:12] PHP Warning: imagedestroy() expects parameter 1 to be resource, boolean given in E:\xampp\htdocs\lib\JpegThumbnail.php on line 44
 
Old February 2nd, 2012, 02:15 PM
Authorized User
 
Join Date: May 2011
Posts: 12
Thanks: 0
Thanked 2 Times in 2 Posts
Default BOOK AND DOWNLOAD CODE TYPO?

Well, I've just found a solution. In the book and download code, line 21 in upload_avatar.php was set like this:
Code:
if (!$_FILES['avatar']['error'])
I have now changed it to this:
Code:
if (isset($_FILES['avatar']['error']))
Everything uploads OK with no error notices. However I think something is not quite right because I realise that I have cancelled the warnings by acknowledging that the errors are set!

Last edited by Albion; February 2nd, 2012 at 03:16 PM..
 
Old February 2nd, 2012, 04:21 PM
Authorized User
 
Join Date: May 2011
Posts: 12
Thanks: 0
Thanked 2 Times in 2 Posts
Default Update

I have just made the following adjustment. It makes more sense and works OK.

Code:
if (isset($_FILES['avatar'])) {

if (!$_FILES['avatar']['error'])
{





Similar Threads
Thread Thread Starter Forum Replies Last Post
Edit user's profile ... Avatar Url: j-parker BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 4 December 24th, 2006 07:12 PM
How can I creat a forum like P2P Forum? pcassiano ASP.NET 1.0 and 1.1 Basics 1 October 31st, 2005 05:00 AM
add a image as your 'avatar' for bookmarks crmpicco HTML Code Clinic 4 September 30th, 2005 03:51 AM
converting Forum.aspx to Forum.ascx (help) drfunkie BOOK: ASP.NET Website Programming Problem-Design-Solution 1 July 11th, 2003 12:27 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.