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 September 3rd, 2010, 06:23 PM
Authorized User
 
Join Date: Apr 2010
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..





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 07:10 PM
Another problem... Chapter 5 mmcdonal BOOK: Beginning VB.NET Databases 4 March 20th, 2005 07:37 PM





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