User login

Cannot access empty property

If you see something like this:

Fatal error: Cannot access empty property in /home/user/public_html/dev/sites/default/modules
/newsletter/newsletter.module on line 163

It probably means you are using $node->field syntax on a variable that doesn't exist, or has a zero value– in other words, an empty property.

And the error is probably being thrown in line 174 or something, because the server doesn't always count lines the same as your text editor.

As for where to fix the error, look in your module's implementation of hook_form to make sure you are naming your form field the same as the $node->field variable you were trying to save.

That will fix future problems. To fix your current node, edit the database directly or delete that node and create it so all the information saves this time.

Please note – especially if you're a client, or considering becoming one – that all of this is based on abstract thought and theorizing, and could not possibly be related to us making the same mistake ourselves.

If you see something like this:

Fatal error: Cannot access empty property in /home/user/public_html/dev/sites/default/modules
/newsletter/newsletter.module on line 163

It probably means you are using $node->field syntax on a variable that doesn't exist, or has a zero value– in other words, an empty property.

And the error is probably being thrown in line 174 or something, because the server doesn't always count lines the same as your text editor.

As for where to fix the error, look in your module's implementation of hook_form to make sure you are naming your form field the same as the $node->field variable you were trying to save.

That will fix future problems. To fix your current node, edit the database directly or delete that node and create it so all the information saves this time.

Please note – especially if you're a client, or considering becoming one – that all of this is based on abstract thought and theorizing, and could not possibly be related to us making the same mistake ourselves.

Comments

One more thing...

Make sure you don't do something really stupid, like throw in an inappropriate dollar sign:

$node->$field instead of $node->field

This must be why the programmers at other firms drink coffee.

Thanks - dollar sign was it!

Thanks - dollar sign was it!

:))

Me to: dollar sign was it! Thanks for post :)

Thanks: Cannot access empty property is fixed now.

Thanks Benjamin Melançon!
i search this on alot of sites but no one give the answer you provide. it was a small mistake of $ sign. Thanks

Damn dollar sign

Yup, that was it here too! Very surprising - the site worked for years with the $node->$field syntax mistake in PHP 4 before I switched it to PHP 5.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.