 |
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 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
|
|
|
|

June 15th, 2004, 09:40 AM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

June 15th, 2004, 11:42 AM
|
|
Authorized User
|
|
Join Date: Apr 2004
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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?
|
|

June 15th, 2004, 01:07 PM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 16th, 2004, 08:25 PM
|
|
Authorized User
|
|
Join Date: Apr 2004
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

June 17th, 2004, 02:22 AM
|
|
Authorized User
|
|
Join Date: May 2004
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 17th, 2004, 02:54 AM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

June 17th, 2004, 07:48 AM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

June 17th, 2004, 09:06 AM
|
|
Authorized User
|
|
Join Date: Apr 2004
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

June 19th, 2004, 12:16 PM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 21st, 2004, 08:39 AM
|
|
Authorized User
|
|
Join Date: Apr 2004
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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?
|
|
 |