mungyun Posted May 3, 2008 Share Posted May 3, 2008 Im having a really difficult time figuring out why im getting this error, i was thrown into a mostly complete ecommerce site and i have php experience but not with anything as object oriented as this and every site ive looked at for this error im getting doesnt seem to answer it because there is something new in this code im not familiar with. I'll try to be as descriptive as i can but if there is anything else anyone needs to know let me know. The error is the call to member function PrintFormatHeader() of a non object the lines involved are $this->form->printFormHeader(); $this->form->drawElementRange(0, 7); $this->form->drawElementRange(7,11); print "<div class = 'form_row'><div class = 'form_left'><input type = 'button' value = 'Shipping Info same as Billing Info' onclick = 'copyForm()' /></div></div>"; $this->form->drawElementRange(11,17); $this->form->printFormFooter(); and form is, as far as i have seen an object being passed to this class. here is the constructor: public function __construct($form, $message){ $this->message = $message; $this->form = $form; } Now, this code is practically identical to another ecommerce site they have completed and they have a backend set of classes that is used to make developing these sites quick. The only thing different in this site im working on is that i removed the login module so they can checkout without logging in. I wouldnt see why that would cause any issues but i guess i cant rule it out either. From what ive read on other sites about this error is that the object isnt being defined correct, so im guessing that $form isnt being passed correctly or something but im not really sure how to test this. I did add an if statement like this to test if form has anything: if($this->form){ print "yes"; }elseif(!$this->form){ print "no"; }else{ print "dunno"; } On the page when i run it i get no printed out so does that mean that form has nothing? or am i doing the wrong thing to test my idea? This site has to be done by monday and i am really in dire need of help so anything anyone has to offer would be greatly appreciated if you need me to post more code or have any questions about where something is, i will gladly add that Link to comment https://forums.phpfreaks.com/topic/104006-member-function-non-object-cant-find-right-answer/ Share on other sites More sharing options...
BlueSkyIS Posted May 3, 2008 Share Posted May 3, 2008 where is the part of the code defining $this? Link to comment https://forums.phpfreaks.com/topic/104006-member-function-non-object-cant-find-right-answer/#findComment-532450 Share on other sites More sharing options...
ablueycolor Posted May 4, 2008 Share Posted May 4, 2008 It would be more appropriate if you used a boolean check to see if $form exists: <?php if (is_object($this->form)) { print('object'); } else { print('non object'); } ?> My first inclination is that you haven't properly instantiated the object. Please try and do a <?php var_dump($form); die; ?> in your constructor to see if the form object is actually being passed as a test and let us know what you find. Also, I would take a look at trying to find what class makes a call to your current class and trace $form back to it's creation to try and find any problems. Perhaps the include was declared in the login module for some reason? Link to comment https://forums.phpfreaks.com/topic/104006-member-function-non-object-cant-find-right-answer/#findComment-532484 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.