Link to home
Start Free TrialLog in
Avatar of Willem Norval
Willem NorvalFlag for South Africa

asked on

undefined variable

I inserted the default value for $custid = 0;     before the first 'if'.   It worked.

However, my previous  carts are not emptied and there's a problem with the total - it only gives the total of the last cart.
And it's now giving this error  :
Notice: Undefined variable: customers_custnum in C:\Xamp\htdocs\chapter15\checkout3.php on line 96
(which is '$total', )
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Willem Norval

ASKER

The error message problem was solved.
The other part of the problem remains  -  why is the cart not emptied of previous orders ?
I don't know.  Is that the temporary file (createtemp.php)?  There is nothing about that in the code you posted on the other question.
Yes, the temporary file was created by createtemp.php,  it's in my database :
CREATE TABLE carttemp(
          carttemp_hidden INT(10) NOT NULL AUTO_INCREMENT,
          carttemp_sess CHAR(50) NOT NULL,
          carttemp_prodnum CHAR(5) NOT NULL,
          carttemp_quan INT(3) NOT NULL,
          PRIMARY KEY (carttemp_hidden),
          KEY(carttemp_sess));
Here's the MySQL database copy
createtemp.docx
I found this feedback on the textbook's forum on the same problem (couldn't quite make out what he means) :
"Please check this !!!!
Notice: a seeion had already been started - ignoring session_start() in c:\inetpub\wwwroot\cms\cart.php on line 3.
the code line reads session_start(); on line 3 of the cart.php page.

2. Notice: use of undefined constant total - assumed 'total' in c:\inetpub\wwwroot\cms\cart.php on line 89.
the code line reads $total = $extprice + $total; on line 89 of the cart.php page.

secondly i also noticed the second problem on the checkout2.php page which reads

Notice: use of undefined constant total - assumed 'total' in c:\inetpub\wwwroot\cms\checkout2.php on line 274.
the code line reads $total = $extprice + $total; on line 274 of the cart.php page.

thirdly, i noticed that the final total is not often correct if you purchase large amount of goods for example i tried to purchase 300 CBA Coffee Mug which cost 8.95 each with extended price which is 2,685.00 and Small Grappling Hook which cost 139.95 each with extending price which is 2, 379.15 and noticed that the total before shipping is reading 4.00 and on the confirmation page its read thesame. i mean 4.00 which is not correct. "
checkout2.php
What book is this?
Beginning PHP5, Apache, MySQL Web Development
By Wrox books