Wrox Programmer Forums

Need to download code?

View our list of code downloads.

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 September 3rd, 2010, 06:23 PM
Authorized User
Points: 88, Level: 1
Points: 88, Level: 1 Points: 88, Level: 1 Points: 88, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2010
Location: Rumford, Rhode Island
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs down problem with chapter 1

I am wending my way through chapter 1 of this book, and for the most part I am using code that was downloaded from the Wrox website, and I am still running into problems.
I couldn't get the random text generator to work properly, so I created one of my own. I found this function on the web, and it didn't work either until I played around with it a bit.
PHP Code:
<?php
// return a string of random text of a desired length
function random_text($count$rm_similar false) {
  
// create list of characters
  
$chars = array("A""B""C""D""E""F""G""H""J""K""L""M""N""P""R""S""T""U""V""W""X""Y",
                             
"Z""2""3""4""5""6""7""8""9");
  
shuffle($chars);
  
// remove similar looking characters that might cause confusion
  
if ($rm_similar) {
    unset(
$chars[0], $chars[1], $chars[2], $chars[5], $chars[8], $chars['B'], $chars['I'], $chars['O'], $chars['S'], $chars['U'],
          
$chars['V'], $chars['Z']);
  }
  
// generate the string of random text
  
$text '';
  for (
$i 0$i $count$i++) {
    
$num mt_rand(0count($chars) - 1);           
    
$text .= $chars[$num];
  }
  return 
$text;
}
?>
If you wanted to you could also add lower case letters or special characters to the array to make the captcha even more complex.

Last edited by Boboneil; September 3rd, 2010 at 06:46 PM.
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
Having a problem in chapter 2 Okie BOOK: Beginning Access 2003 VBA 1 August 9th, 2007 10:30 AM
Chapter 2 problem jnbutler BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 1 June 1st, 2007 08:54 PM
problem on Chapter 5 stzd8 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 November 25th, 2006 06:10 PM
Another problem... Chapter 5 mmcdonal BOOK: Beginning VB.NET Databases 4 March 20th, 2005 06:37 PM



All times are GMT -4. The time now is 01:27 AM.


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