PHP Session with an Incomplete Object -


I am getting an error I do not know how to do it right, so I wonder if I can get some help .

This error is

  Fatal error: process_form () [& lt; A href = 'function.process-form' & gt; Function.process-form & lt; / A & gt;]: The script tried to execute a method or use the property of an incomplete object. Please make sure that the class definition & amp; Quot; Template & quot; The object you are trying to work on was loaded _before_ unserialize () to light 44 / <> 

I get this error in the process_form () function. So what do I get from this point of thinking, I did not load the class for the template. Include what I actually did on the top 'inc / item.class.php'; Do I have to re-add it to the function?

There is a code for a special page with error, you can see that I have everything like it should be. Where did I go wrong?

  & lt ;? Includes Php 'inc / prep.php'; Include 'inc / header.class.php'; Include 'inc / item.class.php'; Include 'inc / template.class.php'; Include 'inc / formhelper.class.php'; Include 'inc / formvalidator.class.php'; Include_once ('inc / config / config.php'); Include_once ('inc / DBE.class.php'); Include_once ('inc / GenFuncs.php'); Include_once ('inc / Search.class.php'); Session_start (); // Verify that the user is logged in. VerifyLogin ($ _ SERVER ['PHP_SELF'] "?" $ _SERVER ['QUERY_STRING']); If (array_key_exists ('_ submit', $ _ POST)) {if ($ fv_errors = validate_form ()) {show_form ($ fv_errors); } And {process_form (); }} Else {// Form was not submitted or preview was selected, so display show_form (); } Function validate_form () {} function process_form () {global $ mysqli; Echo var_dump ($ _ session); $ Template = $ _SESSION ['Template']; $ Template-> Name = $ _POST ['name']; $ Template-> Descript = $ _POST ['descript']; $ Template-> User = $ _SESSION ['user']; $ Template-> Customer = $ _SESSION ['CustID']; $ Template-> Status = $ _POST ['status']; $ Template & gt; Insert (); // headers ("location: template.php"); }   

This is not a serialize / unassignment of your template class.

Take a look here for one, I gave your second question.

For example, you might want to:

   

and

  & lt; Php $ template = unserialize ($ _ session ['template']); ? & Gt;  

Edit:

It shows a hint after reading your comment about going upstairs.

When you call, the automatic serialization / unserialization happens session_start () .
This means that you include your files and calling session_start () is very important.

For example:

This would be wrong:

   

However this would be true:

   

Now, in my example, I see that it is in the right order, but I note that you include many others before adding template.class.php < / P>

It is possible that one of these (probably prep.php or header.class.php) calls start_session () ?
If so, this was your problem ( session_start () is being called before your template.class.php.)


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -