Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8
This is the forum to discuss the Wrox book Professional CodeIgniter by Thomas Myer; ISBN: 9780470282458
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 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 Display Modes
  #1 (permalink)  
Old November 17th, 2008, 01:46 PM
Registered User
 
Join Date: Nov 2008
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Php Error when calling the cart() control function

Hello,
If i understand everything ,when it call the cart() function from the controller,

Code:
    function cart($productid){
    if ($productid > 0) {
If customer click on add to cart then the $productid will be pass but this function is also dispyaing the content of the cart and this time the $productid is NULL (echo "†".anchor("shopping/cart","view cart");)

so this is causing two notice php error, i think i can find a way to fix but maybe i miss something here?
Any idea?
thx, and great book so far :)

Reply With Quote
  #2 (permalink)  
Old November 17th, 2008, 01:58 PM
Registered User
 
Join Date: Nov 2008
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

also when i m connect to the home page with nothing in my cart yet i ve got this error message,

 
Quote:
quote:
Quote:
Severity: Notice

Message: Undefined index: cart

Filename: views/header.php

Line Number: 11
this is the line:
if (count($_SESSION['cart']) == true){

i think both error message are related but cannot find my error...
thx!

Reply With Quote
  #3 (permalink)  
Old January 10th, 2009, 12:28 PM
Registered User
 
Join Date: Dec 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm having this same issue. Anyone know what the problem is. It's the books code so it would be great if the author could pitch in to renedy this otherwise I, and others can't finish building the app.
Reply With Quote
  #4 (permalink)  
Old January 10th, 2009, 01:47 PM
Registered User
 
Join Date: Aug 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Possible Solution

Not sure if this helps, I can't remember if this fixed it when I was going through the book but I made a note on page 111 that where it says:
Code:
$nav['navlist'] = $this->MCats->getCategoriesNav();
it should read
Code:
$data['navlist'] = $this->MCats->getCategoriesNav();
I remember that this was the source of an error message I was getting but not sure if it the same one you are getting.
Reply With Quote
  #5 (permalink)  
Old January 11th, 2009, 05:47 AM
Registered User
 
Join Date: Dec 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That's worked a treat. Thanks for that!!!!
Reply With Quote
  #6 (permalink)  
Old February 3rd, 2009, 09:31 AM
Registered User
 
Join Date: Feb 2009
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
Default To remove the bug "Undefined Index : cart"

In \system\application\models\morders.php, after //pull in existing cart first!
just put this line :

Code:
$cart = isset($_SESSION['cart']) ? $_SESSION['cart'] : array();
It should look like this now :

Code:
function updateCart($productid,$fullproduct){
	//pull in existing cart first!
	$cart = isset($_SESSION['cart']) ? $_SESSION['cart'] : array();
And no more "Undefined Index : cart" anymore !!!!
Reply With Quote
The Following User Says Thank You to wanadoobtdc For This Useful Post:
phpcoder101 (November 5th, 2009)
  #7 (permalink)  
Old February 3rd, 2009, 03:31 PM
Registered User
 
Join Date: Dec 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quick reply. Haven't tried it yet but a big thanks!
Reply With Quote
  #8 (permalink)  
Old March 16th, 2009, 11:02 AM
Wrox Author
 
Join Date: May 2008
Location: Austin, TX, USA.
Posts: 53
Thanks: 0
Thanked 5 Times in 5 Posts
Default dangit, I've been answering questions in the wrong places

Guys, I am so sorry. I've been answering questions via email. Yes on both counts, the $nav array should be $data, and yes, the original code has an isset() for the shopping cart, but didn't get inserted back into the text of the book.

if anyone wants to see my copy of the code, simply send an email to tom AT tripledogs DOT com. I will send you an archive.
__________________
Thomas Myer
Author, Professional CodeIgniter
http://www.tripledogs.com
Reply With Quote
  #9 (permalink)  
Old November 14th, 2011, 06:59 AM
Registered User
Points: 25, Level: 1
Points: 25, Level: 1 Points: 25, Level: 1 Points: 25, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2006
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by krifur View Post
Hello,
If i understand everything ,when it call the cart() function from the controller,

Code:
    function cart($productid){
    if ($productid > 0) {
If customer click on add to cart then the $productid will be pass but this function is also dispyaing the content of the cart and this time the $productid is NULL (echo "†".anchor("shopping/cart","view cart");)

so this is causing two notice php error, i think i can find a way to fix but maybe i miss something here?
Any idea?
thx, and great book so far :)
Hi

Can you or anyone else please tell me how did you solve this problem?

I am trying to get around it, but I am unable to solve it?

I am getting those two errors thrown at my face again and again:

A PHP Error was encountered

Severity: Warning

Message: Missing argument 1 for Welcome::cart()

Filename: controllers/welcome.php

Line Number: 68

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: productid

Filename: controllers/welcome.php

Line Number: 70


Regards, Zoreli
Reply With Quote
  #10 (permalink)  
Old February 23rd, 2012, 08:02 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hey i am getting the same errors any update on it??
Reply With Quote
Reply


Thread Tools
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
Free php shopping cart heerajee Pro PHP 1 April 20th, 2006 03:32 PM
chapter 15 cart.php pink BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 July 18th, 2005 06:45 PM
http_client.php shopping cart error boetheus Beginning PHP 0 November 21st, 2004 11:22 AM
shopping cart in php isheikh PHP How-To 1 October 22nd, 2004 09:17 PM
PHP Source Code for Shopping cart haribabu PHP How-To 0 January 27th, 2004 02:10 AM



All times are GMT -4. The time now is 02:13 PM.


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