Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 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 Search this Thread Display Modes
  #1 (permalink)  
Old June 15th, 2004, 09:40 AM
Registered User
 
Join Date: Jun 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default ch.14 file errors

I have been trying to get the shopping cart working and wondered if any errata had been listed.
I get errors about the variable $total not being defined and though I have been able to add code to rectify this I also had to define a variable $subtotal in cart.php as number_format() in conjunction with $extprice caued problems when an item value exceeded 1,000.

My main issues however are that
1. NOthing is added to ordermain when checkout3.php is executed, despite a new customer being added to the customers table.

2. The final synopsis of the cart in checkout3.php alters the quantity of each item so that they all end up with the same quantity. This ultimately results in a false order.

Reply With Quote
  #2 (permalink)  
Old June 15th, 2004, 11:42 AM
Authorized User
 
Join Date: Apr 2004
Location: Cincinnati, OH, USA.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Are you getting any mysql errors in the checkout3.php, or is it just not adding the order information?

Also- let me investigate the $quan variable and get back to you.

What version of PHP are you running?

Reply With Quote
  #3 (permalink)  
Old June 15th, 2004, 01:07 PM
Registered User
 
Join Date: Jun 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am running PHP version 4.3.3.3
No mysql errors on the checkout3.php page. I've tried a few echo statements just to make sure the code is working around it and there aren't any problems. Also, I copied the INSERT statement into MySQL control center and substituted actual values for the variables and that worked ok. I don't think I altered anything that would have caused this to not work, so any explanation or confirmation that it works elsewhere would be welcome.
Thanks

Reply With Quote
  #4 (permalink)  
Old June 16th, 2004, 08:25 PM
Authorized User
 
Join Date: Apr 2004
Location: Cincinnati, OH, USA.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, I've figured out what the problem was. The information was loading into the database correctly, it was just echoing the wrong variable to the browser.

Please make the following changes to checkout3.php (a formal errata will also be added for this)

line 179: change the variable $quan to $qty
line 189: change the variable $quan to $qty
line 288: change the variable $quan to $qty
line 289: change the variable $quan to $qty

This should solve your problem.


Reply With Quote
  #5 (permalink)  
Old June 17th, 2004, 02:22 AM
Authorized User
 
Join Date: May 2004
Location: , , .
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by ElizabethN
 line 179: change the variable $quan to $qty
line 189: change the variable $quan to $qty
line 288: change the variable $quan to $qty
line 289: change the variable $quan to $qty
Or:
$lines = array(179, 189, 288, 289);
foreach ($lines as $line_number) {
  echo "line $line_number: change the variable $quan to $qty";
}

/me ducks and runs
:D

Michael K. Glass
Author, Beginning PHP, Apache, MySQL Web Development
Reply With Quote
  #6 (permalink)  
Old June 17th, 2004, 02:54 AM
Registered User
 
Join Date: Jun 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, that worked alright. I think the last line referenced should be 298 and not 289.

Still having trouble with the order number displayed on checkout3.php. It displays the customer number instead and this is also the number stored under 'ordernum' in the orderdet table. Finally, the ordermain table remains without records.

Reply With Quote
  #7 (permalink)  
Old June 17th, 2004, 07:48 AM
Registered User
 
Join Date: Jun 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The problem with the order not being generated in the ordermain table is the result of the inclusion of 'shipping' in the INSERT statement for ordermain. Though it is a valid field in the ordermain table, a value for $shipping is not defined on the checkout3.php page. Removing references to 'shipping' from the INSERT statement have sorted it out.

I really like the layout and pace of the book, it is much more accessible than others I have looked at but the extra time spend on altering simple errors in the scripts has been offputting.

Reply With Quote
  #8 (permalink)  
Old June 17th, 2004, 09:06 AM
Authorized User
 
Join Date: Apr 2004
Location: Cincinnati, OH, USA.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, I finally figured out our solution.

Line 77 of checkout3.php needs a comma at the end. (It all comes down to a comma :) )

It should read:
 '$shipping',

Again, a formal errata will be submitted. Thanks for your patience and understanding. Believe it or not, this code was fully tested prior to publication ;) Let us know if you have any more problems.

Reply With Quote
  #9 (permalink)  
Old June 19th, 2004, 12:16 PM
Registered User
 
Join Date: Jun 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I too am having an issue with cart.php from CH.14 as the $total variable is coming up undefined. Also, when I add an item to my cart, go back and add another item to my cart, the total comes up only as the last item I added to my cart. It doesn't add the multiple extprice columns to equal a correct total AND sets all quantities to the last quantity I added to my cart. I changed all the $quan to $qty in cart.php as quantity's variable is declared as $qty every where else. I downloaded the code directly from this site as well.

I have only programmed up to change.php and delete.php,but I would assume each should be able to run "up to the point I've programmed".

I think all my issues may be due to this $total not being declared, but I dunno. I could use a little help though.

Sincerely,
Shawn Berg

Reply With Quote
  #10 (permalink)  
Old June 21st, 2004, 08:39 AM
Authorized User
 
Join Date: Apr 2004
Location: Cincinnati, OH, USA.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The beauty of PHP is that you don't have to declare a variable prior to using it- it figures out what type of variable it is based on the value you initially assign to it. The only time there is a conflict (a warning - not an error) is when you reference the variable to itself before it has been initialized ($total = $total + $extprice).

You can remedy this 2 ways:
1) change your php.ini error reporting level
2) insert a line to "initialize" the variable that is giving you the error - $total = "";

The warning will not halt execution of the script, it is merely a warning.

As far as the change.php and delete.php files, they test fine on my machine with the variables as-is. Remember that we are going between $qty and $quan for the temporary cart purposes. I'm not sure why you would be getting these errors- this has been tested using PHP 4.3.7. What version are you using?

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
DataRowView Type Not Defined (CH 14) kmwilliams5 ASP.NET 3.5 Basics 5 April 25th, 2009 05:07 AM
CH 14 Pages 749-753 Compile Errors Razzy The Pug BOOK: Ivor Horton's Beginning Visual C++ 2005 1 March 28th, 2008 10:20 AM
Chap 14 Errors russconnor BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 1 July 4th, 2006 07:11 AM
CH. 14 Stored Procedure mcauliff BOOK: Beginning ASP 3.0 1 October 4th, 2005 01:52 PM
Ch. 14 Calendar Modification Astalder BOOK: Beginning ASP.NET 1.0 6 December 1st, 2004 06:23 PM



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


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