"Claudia's Kids" wrox shopping tutorial: function updateCart() on a non-object |
[eluser]antoniog[/eluser]
I'm doing the tutorial from the book "Professional CodeIgniter" published by Wrox. At this point in the tutorial, click on "add to cart" above the image should appear to me the two following pieces of code, the first enclosed in a box with a red edge. First part of code (in the box): Code: A PHP Error was encountered Second part of code: Code: Fatal error: Call to a member function updateCart() on a non-object in /home/youngtea/public_html/igniter/application/controllers/welcome.php on line 88 Code of welcome.php (the controller) Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); At the moment I can not get to the bottom of the issue. Thank you for help to all.
[eluser]CroNiX[/eluser]
Are you loading MOrders, whatever that is? Model I assume? Actually, I only see you load the session and cart libraries, so I'm not sure how any of this is working. MCats, MOrders and MProducts don't seem to be loaded here unless they are loaded somewhere else.
[eluser]Ayeyermaw[/eluser]
I don't have the book so I can't give you a specific answer but what I can tell you is that MOrders has not been loaded. I'm assuming with the name of MOrders, MCats and MProducts that they are models. I'm also assuming that the other two models aren't throwing errors therefore are loaded. Check application/config/autoload.php (I assume that's where you're loading them from as you haven't done so in the copntroller). EDIT: Cronix beat me to it :p
[eluser]InsiteFX[/eluser]
@CroNiX, The tutorial has them autoloaded. There is alot more then that wrong with that tutorial! I have already converted it to CI 2.1.0 and it was no fun, there are errors even in the view files! The only thing that I did not convert was the shopping cart because I feel it should be converted over to CI's Shopping Cart Class, someday I'll get around to it.
[eluser]CroNiX[/eluser]
Maybe he forgot MOrders then, because those error messages indicates it doesn't exist. I know this isn't the first time someone has posted problems about that particular tutorial..
[eluser]antoniog[/eluser]
[quote author="CroNiX" date="1337270803"]Are you loading MOrders, whatever that is? Model I assume? Actually, I only see you load the session and cart libraries, so I'm not sure how any of this is working. MCats, MOrders and MProducts don't seem to be loaded here unless they are loaded somewhere else.[/quote] Yes MOrders is a model and it is loaded by autoload.php like the other models.
[eluser]CroNiX[/eluser]
The problem could be in the model code then, which you should also post.
[eluser]antoniog[/eluser]
[quote author="Ayeyermaw" date="1337271204"]I don't have the book so I can't give you a specific answer but what I can tell you is that MOrders has not been loaded. I'm assuming with the name of MOrders, MCats and MProducts that they are models. I'm also assuming that the other two models aren't throwing errors therefore are loaded. Check application/config/autoload.php (I assume that's where you're loading them from as you haven't done so in the copntroller). EDIT: Cronix beat me to it :p[/quote] In real MOrders had not been added to autoload.php. Sorry my mistake they are all a little apprehensive as I already work on my project.
[eluser]antoniog[/eluser]
[quote author="InsiteFX" date="1337271446"]@CroNiX, The tutorial has them autoloaded. There is alot more then that wrong with that tutorial! I have already converted it to CI 2.1.0 and it was no fun, there are errors even in the view files! The only thing that I did not convert was the shopping cart because I feel it should be converted over to CI's Shopping Cart Class, someday I'll get around to it. [/quote] Thank you.
[eluser]antoniog[/eluser]
[quote author="CroNiX" date="1337271669"]Maybe he forgot MOrders then, because those error messages indicates it doesn't exist. I know this isn't the first time someone has posted problems about that particular tutorial..[/quote] Yes I have forgot insert MOrders in autoload. |
Welcome Guest, Not a member yet? Register Sign In |