Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1
This is the forum to discuss the Wrox book Professional PHP5 by Ed Lecky-Thompson, Heow Eide-Goodman, Steven D. Nowicki, Alec Cove; ISBN: 9780764572821
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 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
  #1 (permalink)  
Old February 27th, 2005, 06:48 PM
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default chapter 13 - MVC

Has anyone gotten the chapter 13 (Model, View, Controller) example working with the code available for download? I downloaded the code and have been testing the search, but it's not working when you enter input that violates the constraints. I've been trying to figure out how to make it work, but I haven't gotten it yet. I've narrowed it down some, but I don't completely understand all the code at this point.

Unfortunately, it seems like other people have been having issues with errors elsewhere throughout the book. This is the first code example I've actually tried from the book. So far, it's been an interesting read, but I wish it'd WORK :(

I'm running IIS 5.1 with PHP 5.0.3 on Windows XP Pro.

Thanks.
  #2 (permalink)  
Old February 28th, 2005, 06:26 PM
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well...... after about 3 hours of debugging (which nearly drove me insane), I found the problem is simply a TYPO in constraint.phpm.

Code:
  function GetConstraintType() {
    return($this->_intContraintType);
  }


should be

Code:
  function GetConstraintType() {
    return($this->_intConstraintType);
  }


I'm going to attempt to submit it to the errata section. Hopefully wrox gives a crap.

  #3 (permalink)  
Old March 5th, 2005, 03:46 PM
Registered User
 
Join Date: Mar 2005
Location: Heemstede, n/a, Netherlands.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a million! You saved me hours...
Quote:
quote:Originally posted by omarosa
 Well...... after about 3 hours of debugging (which nearly drove me insane), I found the problem is simply a TYPO in constraint.phpm.

Code:
  function GetConstraintType() {
    return($this->_intContraintType);
  }
should be

Code:
  function GetConstraintType() {
    return($this->_intConstraintType);
  }
I'm going to attempt to submit it to the errata section. Hopefully wrox gives a crap.

Hillechien
  #4 (permalink)  
Old March 11th, 2005, 01:22 PM
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I noticed when you add a few more constraints than what they have in the example, then it doesn't work. It returns back to the original page, but without the error messages. I've been going through this forever trying to figure out where the problem is. Anyone else know? Or have a working example and code they could show?

  #5 (permalink)  
Old March 12th, 2005, 08:45 PM
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK, I think the problem is that the cookie is getting too big. I logged the value of the phprqcOriginalRequestObject cookie, and it is set only if I 1) add less constraints with more POST variables, or I 2) use more constraints but use a smaller number of POST variables. Great.

I thought cookie values are just supposed to be truncated, but whatever. I admit I don't know much about them, but... argh.
  #6 (permalink)  
Old March 24th, 2005, 06:58 PM
Registered User
 
Join Date: Mar 2005
Location: West Chester, PA, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'd like to second hillechien's thanks. Once I prepended searchresults.php with my local path to search.php everything worked as described in the book.

I have the following reservations about the code:

1. The amount of commenting for complex code, particularly in an educational setting, is atrocious.

2. Page 263 states that "There is no provision in the example for displaying YOUR SEARCH PRODUCED NO RESULTS message. However, the implementation of such a message would be relatively straightforward." If it is so easy to implement, why not complete the code and eliminate the confusion caused by getting "empty" results back? One of the major criticisms of this book is that it was difficult to determine if you were dealing with a lack of understanding of the example code or true bugs. That is not an ideal learning experience.

I have read the other comments about this book at the forum and they are generally negative. I like the structure and the selection of "professional" topics. I wish that the implementation had been more professional. There is a huge need for a book such as this and I am not sure that there are decent alternatives currently (anybody have one?). I would rather that Wrox not be defensive about the current edition and simply come up with a plan to resolve the deficiencies. The most obvious is to list the errata on-line. Maybe Wrox feels that the amount of errata would kill sales of the current edition. That might be the good news for all concerned, including Wrox. I don't know why they would wish to damage their reputation by implying that the book in its current state represents acceptable Wrox quality.

  #7 (permalink)  
Old March 24th, 2005, 08:32 PM
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

A note on the last issue I was having with not being able to add more constraints -- I'm temporarily just creating a new request object and testing the constraints for every few constraints I add. This is probably fine for verifying a few things, but I have a couple pages with big forms that it will probably hurt. It's fine with a couple users doing it, but with a substantial amount of traffic, I dunno... I'm still not sure why the problem is occurring.

  #8 (permalink)  
Old April 6th, 2005, 05:45 PM
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hmm.... got it to work.

I'm not sure why it wouldn't write the cookie, but I tried using gzcompress/gzuncompress before/after writing the cookie and now it works. You can add as many constraints now and only call TestConstraints() once. Creating additional new requests and calling TestConstraints() was not actually doing what I expected, and was screwing up some other things as well.

I based my code off this example code from http://us3.php.net/manual/en/function.serialize.php :

Code:
<?php
$data[qwerty] = "blah";
$data[1][a] = "1aa";
$data[2][b] = "2bb";
$data[3][c] = ";;;;;;";
$data[name][first] = "Bob";
$data[name][last] = "Jones";
$data[val] = "This is a real long test string, to see how well the compression works!";

//To Serialise Call :
$string = gzcompress(serialize($data), 9);
setcookie("my_var", $string, time()+60*60*24*60, '/');
//print "String: $string\n<br>"; //uncomment to see serialized array

//To Unserialize Call
if (isset($_COOKIE[my_var])) {
  $array = unserialize(gzuncompress($_COOKIE[my_var]));

  echo "<pre>";
  print_r($array);
  echo "</pre>";
}
?>
Essentially, the only changes are (in request.phpm):

in __construct(...)
Code:
$origObj = unserialize(gzuncompress($cookieVal));
in TestConstraints()
Code:
$strSerialization = gzcompress(serialize($objToSerialize), 9);
HTH.


  #9 (permalink)  
Old April 26th, 2005, 09:26 AM
Registered User
 
Join Date: Apr 2005
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

can any one help me??????

can't find error parse error.... unexpected $ at end of prog.

  #10 (permalink)  
Old March 24th, 2009, 07:45 AM
Registered User
 
Join Date: Feb 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

it's bug?

I want testing is valid email, and...

Code:
$objConstraint = new constraint(CT_MUSTMATCHREGEXP, "/^[^@\s<&>]+@([-a-z0-9]+\.)+[a-z]{2,}$/i");
$this->request->AddConstraint("reg_email", VERB_METHOD_GET, $objConstraint);
Notice: unserialize() [function.unserialize]

incorrect "\"




Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 13 bwoll BOOK: Beginning Access 2003 VBA 1 June 7th, 2007 03:57 PM
Should I go past chapter 13? bossman21 BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 4 July 24th, 2006 12:42 PM
Chapter 13 ElMorenito BOOK: Beginning ASP 3.0 0 January 14th, 2005 02:56 PM





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