Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143
This is the forum to discuss the Wrox book Beginning PHP 6, Apache, MySQL 6 Web Development by Timothy Boronczyk, Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz; ISBN: 9780470391143
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 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 August 9th, 2010, 08:20 AM
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
Smile more errors from chapter 15 - ecomm_checkout3.php

First of all, in order to even get to this page, you will need to add a "submit" button to the form in ecomm_checkout2.php, since the geniuses who wrote the book forgot to add it.

When you attempt to display the page ecomm_checkout3.php, you will get a mysql error message, because the value of the variable $cost_subtotal is empty. They attempt to set the value in the following lines of code:
// retrieve subtotal
$query = 'SELECT
SUM(price * order_qty) AS cost_subtotal
FROM
ecomm_order_details d JOIN ecomm_products p ON
d.product_code = p.product_code
WHERE
order_id = ' . $order_id;
$result = mysql_query($query, $db) or (mysql_error($db));
$row = mysql_fetch_assoc($result);
extract($row);

This does not work. If you change it to the following, it works fine and your page should load with the proper values in all fields:
//retrieve subtotal
$query = 'SELECT
SUM(price * order_qty) AS cost_subtotal
FROM
ecomm_order_details d JOIN ecomm_products p ON d.product_code = p.product_code
WHERE
order_id = ' . $order_id;
$result = mysql_query($query, $db) or die(mysql_error($db));
$row = mysql_fetch_array($result);
$cost_subtotal = $row['cost_subtotal'];
Reply With Quote
  #2 (permalink)  
Old September 8th, 2010, 10:47 AM
Authorized User
Points: 152, Level: 3
Points: 152, Level: 3 Points: 152, Level: 3 Points: 152, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2010
Location: Bra - Italy
Posts: 36
Thanks: 1
Thanked 1 Time in 1 Post
Default

Thanks Boboneil.. very useful!!

Perhaps you have saw the error in the Chp12.. I've open a thread about that..

I ask myself: but the people who wrote this book.. didn't TRY all the script??? I'ts unbelivable...

(sorry for the english but i'm Italian..)
Reply With Quote
  #3 (permalink)  
Old September 8th, 2010, 01:45 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
Default

By the time I got to chapter 16 I gave up trying to fix the errors. There is so much code involved in that chapter that it would take forever to fix it. I have moved on to a more advanced PHP book - "PHP and MYSQL Create - Modify - Reuse". This one is from Wrox also and it seems to be pretty good, though I am having problems with some of the code in it.
I saw your post about chapter 12, but I could not recreate the problem, so I don't know how to resolve it.
Reply With Quote
  #4 (permalink)  
Old September 8th, 2010, 03:29 PM
Authorized User
Points: 152, Level: 3
Points: 152, Level: 3 Points: 152, Level: 3 Points: 152, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2010
Location: Bra - Italy
Posts: 36
Thanks: 1
Thanked 1 Time in 1 Post
Default

I understand, thanks however..
Just i terminate the book i look for something more "precise",but i will take a look to "PHP and MYSQL Create - Modify - Reuse".. is like a sequel of "BOOK: Beginning PHP 6, Apache, MySQL 6" ?? If yes seems interesting
Reply With Quote
  #5 (permalink)  
Old September 8th, 2010, 04:19 PM
Authorized User
Points: 152, Level: 3
Points: 152, Level: 3 Points: 152, Level: 3 Points: 152, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2010
Location: Bra - Italy
Posts: 36
Thanks: 1
Thanked 1 Time in 1 Post
Default

Ok Ok i solve it! More simple than i thought!

There is the original portion of code that update the user info
PHP Code:
$query 'UPDATE site_user u, site_user_info SET
            username = "' 
mysql_real_escape_string($username$db) . '",
            first_name = "' 
mysql_real_escape_string($first_name$db) . '",
            last_name = "' 
mysql_real_escape_string($last_name$db) . '",
            email = "' 
mysql_real_escape_string($email$db) . '",
            city = "' 
mysql_real_escape_string($city$db) . '",
            state = "' 
mysql_real_escape_string($state$db) . '",
            hobbies = "' 
mysql_real_escape_string(join(', '$hobbies), $db) . '"
          WHERE
            u.user_id = ' 
$user_id
and there is the modified code, now it works
PHP Code:
$query 'UPDATE site_user u, site_user_info i SET
            username = "' 
mysql_real_escape_string($username$db) . '",
            first_name = "' 
mysql_real_escape_string($first_name$db) . '",
            last_name = "' 
mysql_real_escape_string($last_name$db) . '",
            email = "' 
mysql_real_escape_string($email$db) . '",
            city = "' 
mysql_real_escape_string($city$db) . '",
            state = "' 
mysql_real_escape_string($state$db) . '",
            hobbies = "' 
mysql_real_escape_string(join(', '$hobbies), $db) . '"
          WHERE
            u.user_id = ' 
$user_id ' AND i.user_id = ' $user_id
very very simple now i copy it in the right thread

Last edited by DMatt; September 8th, 2010 at 04:22 PM..
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
PHP 4 chapter 15 angelic_scars BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 0 November 29th, 2006 08:36 AM
chapter 15 checkout3.php problem derrida BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 November 12th, 2006 10:11 AM
chapter 15 cart.php pink BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 July 18th, 2005 05:45 PM
Chapter 15 - functions.php question buzzuh BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 September 7th, 2004 08:31 AM
chapter 15 adv_mail.php ncliche BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 2 January 14th, 2004 03:43 PM



All times are GMT -4. The time now is 05:48 PM.


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