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 October 16th, 2010, 10:54 PM
Registered User
 
Join Date: Sep 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default captcha.php

i copied files into directories structured as recommended. but captcha does not display on register.php page. also if u fill in fields but leave 'verify' field [where you enter captcha text] blank, registration works fine. since i copied the files from the website, there are no typos by myself in the code. any ideas?
 
Old October 17th, 2010, 12:54 PM
Authorized User
 
Join Date: Jul 2009
Posts: 77
Thanks: 4
Thanked 6 Times in 6 Posts
Default

Hi,

When writing an image such as the captcha image, you have
to be careful not to send any other output to the browser.
In captcha.php, if you are using print statements for
debugging it is best to take them out. Also, if you have
blank lines after the <?php ?> tags these can get sent
to the browser and cause problems as well.

The thing that can make debugging a little bit difficult
in the case of writing images,
is that it may not be the code logic that is causing the problem;
having other output going to the browser, such as
print statements and blanks lines, can cause the image to
not come out.

See posts

Chap 1 - captcha.php and debugging statements

Chap 9, Debugging issues, and graphs not showing up.

There have been some mistakes in this chapter. I don't know
if they have corrected them since the last time I used them, but
it would be a good idea to check through errata and this
P2P forum.

I hope this helps.
 
Old October 17th, 2010, 07:52 PM
Registered User
 
Join Date: Sep 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default captcha ch.1

thank you kenj. I have doubled checked the .php files. I downloaded them all from this website and copied them into the recommended directory structure. I have not added any debugging statements to the files. Just in case, i have closed up any single line gaps in the code in the functions.php and captcha.php files plus the html section of the register.php file. This has not rectified the issue. I have also checked the errata but there is nothing for chapter 1, captcha. When i first logged in here several weeks ago, i remember seeing a posting where someone complained of this issue and they copied an alternative captcha.php code file which they created and which worked. I have done a search but i have not located that posting. I am not sure why that posting has disappeared. It might solve this matter if someone could help me to retrieve that posting?
 
Old October 19th, 2010, 01:39 AM
Authorized User
 
Join Date: Jul 2009
Posts: 77
Thanks: 4
Thanked 6 Times in 6 Posts
Default

Thank you Andrew.

I downloaded the current captcha.php
file and it appears to be the same as
the one I am using. In the functions
file, captcha.php uses random_text function,
which also appears to be the same as I
am using. Your code should be the
same as mine, and mine is working.
Just to make sure, I did another test;
I replaced my existing captcha.php and
functions.php with these downloaded files.
It worked for me, I was able to see the
captcha image. I was sure to clear temporary
Internet files and cache.

I am wondering if it might have something
to do with system configuration.

I am using

UNIX 4.10-RELEASE FreeBSD
PHP version 5.2.14

At this point, a good test might be to see
if imagepng can write to a file.
Change the imagepng statement, around line 38, to
PHP Code:
imagepng($image,'myfile.png'); 
Browse to register.php
Then go to the public_files/img directory
and see if myfile.png is there.
If it is, see if it will display in the browser
http://mydomain/myapp/public_files/img/myfile.png

Be sure to change that line back again.

If it does display correctly,
then you would have to look at issues around imagepng.
The imagepng function writes to a temporary file which
gets sent to the browser. Perhaps Php does not
have permission to write to the temporary file
or something like that. There is a lot of discussion
about this type of problem on the net.

If it does not display correctly, then you'd
need to go through your code line by line and
see where it is not working.

You may have already done this test,
but I thought I'd post it here anyway
in case anyone else may be interested.

Let us know what happens. Thanks.
 
Old October 19th, 2010, 01:06 PM
Registered User
 
Join Date: Sep 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default captcha ch.1

hello Kenj, thank you for another useful response. I have wrestled with this problem for the last 24 hours and managed to solve it. I tried using captcha source files from php.net and i managed to get a few images working. Eventually I tried out the ch.1 .php files in my browser and the captcha image displayed perfectly. After following so many different paths I was unsure what had caused the image to display all of a sudden.

Your testing is a useful tool. I think you identify the problem when you mention clearing the browser cache.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chap 1 - captcha.php and debugging statements kenj BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 0 September 25th, 2010 08:08 PM
captcha digink BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 December 15th, 2009 06:25 AM
Captcha wulm4321 BOOK: Professional DotNetNuke Module Programming ISBN: 978-0-470-17116-5 1 November 29th, 2009 09:37 PM
CAPTCHA Code MunishBhatia ASP.NET 2.0 Basics 2 December 24th, 2007 03:49 AM
PHP Captcha Script not rendering images - broken crmpicco Beginning PHP 2 October 13th, 2007 07:45 AM





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