Jump to content

[SOLVED] Fatal Error - Classes Help


mike177

Recommended Posts

Hi, I have been writing my own login script for my site. I have completed the registration systems and now working out all the errors - problem is I'm using classes and something’s going wrong.

 

I get a fatal error when I try to use a function located in another file. I've tried making the functions public, global - everything. I can't find any descent tutorials so it's no longer a self-help issue.

 

The exact error message is: Fatal error: call to a member function on a non-object in /home/www/mnielsen.awardspace.com/login/files/session.php on line 31.

 

I've attached the complete source code for the registration system. The errors are occurring in the session.php file on line 31 and the database_functions.php file on line 16 and 24.

 

Thanks in advance for any help

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

Well, for starters I don't see how $form is set in your register() method within the Session class. Also, the function setError() that it's calling is not defined within you Session class. Unfortunately it doesn't look like you yet understand the basics of OOP. It's a good start though.

 

I think you need to pick up a book on PHP - there are lots with OOP style.

 

Our tutorials:

 

http://www.phpfreaks.com/tutorial_cat/19/Object-Oriented-Programming.php

 

Google the web, there's lots.

 

Link to comment
Share on other sites

You have a typo for starters,

else if($datbase->emailTaken($subemail)){

Plus you'll have to do a

global $database;

 

inside the function(register) you're trying to use your database class in. Making it global outside of the class might work too, I'm not sure, I never use globals.

Link to comment
Share on other sites

Well, for starters I don't see how $form is set in your register() method within the Session class. Also, the function setError() that it's calling is not defined within you Session class. Unfortunately it doesn't look like you yet understand the basics of OOP. It's a good start though.

 

I think you need to pick up a book on PHP - there are lots with OOP style.

 

Our tutorials:

 

http://www.phpfreaks.com/tutorial_cat/19/Object-Oriented-Programming.php

 

Google the web, there's lots.

---------------------

Thanks so much, I forgot 1 line at the start of the function.

 

Cheers mate

Link to comment
Share on other sites

You have a typo for starters,

else if($datbase->emailTaken($subemail)){

Plus you'll have to do a

global $database;

 

inside the function(register) you're trying to use your database class in. Making it global outside of the class might work too, I'm not sure, I never use globals.

-------------------

Cheers mate, I did just need to make the $database and form objects global

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.