EllisLab text mark
Advanced Search
     
On new server error: “Trying to get property of non-object”
Posted: 05 September 2007 12:35 PM   [ Ignore ]
Joined: 2007-03-09
7 posts

Today I moved my application to a new server and since hours I can’t figure out what’s wrong.

1. On the old server (Apache 2, PHP 4.3.10-22, MySQL 4.0.24) everything is fine.

2. On the new server - with the same code and database - I get many “A PHP Error was encountered: Trying to get property of non-object” errors. (Apache 2. PHP 5.2.0-8+etch7, MySQL 5.0.32). The errors occur (as I can see) whenever I use validation constructions like

<?=($this->validation->priv_phone) ? ($this->validation->priv_phone) : ($contact_data->priv_phone);?> 

3. To check if there’s a problem with my new server’s configuration I installed XAMPP (http://www.apachefriends.org / Apache 2, PHP 5.2.1, MySQL 5.0.37) on my local Linux machine. Same problems.

Any hints, what can be wrong? I’m confused because in all cases it’s the same code.

 
Posted: 05 September 2007 12:52 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2006-06-23
370 posts

I’d look at getting that PHP 5 version updated. It’s slightly old and there were known problems in the 5.2.0 distribution. It’s possible it’s not passing and setting variables correctly in the view.

 Signature 

Mac OS X 10.8, Apache 2.x, NGiNX, PHP 5.4.x, CodeIgniter 1.7.2/2.1.3

 
Posted: 05 September 2007 01:18 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2007-03-09
7 posts

So I need to compile PHP myself on the Debian Etch server? Do you now a good tutorial where this is explained step by step?

 
Posted: 05 September 2007 03:01 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2007-03-09
7 posts

Switched in XAMPP to PHP4 and everything is immediately right. Coolfactor, I’m pretty sure, that your assumption is correct; though I wonder, why nobody else has troubles with 5.2.x. Nobody running Debian Etch?

 
Posted: 05 September 2007 05:54 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2007-03-09
7 posts

Upgraded to 5.2.3 without success: same errors as in 5.2.0 und 5.2.1 :-(

Is it possible that there’s a compatibility issue with CodeIgniter an these PHP versions?

 
Posted: 05 September 2007 06:09 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2006-06-23
370 posts
ortsanfang - 05 September 2007 09:54 PM

Upgraded to 5.2.3 without success: same errors as in 5.2.0 und 5.2.1 :-(

Is it possible that there’s a compatibility issue with CodeIgniter an these PHP versions?

Not sure what to suggest. However, I would avoid shortcuts and the awkward code you have here:

<?=($this->validation->priv_phone) ? ($this->validation->priv_phone) : ($contact_data->priv_phone);?> 

1. don’t use the short tags
2. you don’t need brackets around atomic values

I’d write it like so:

<?php echo ($this->validation->priv_phone $this->validation->priv_phone $contact_data->priv_phone); ?> 

I doubt that’s the source of the problem, but it was worth a shot.

 Signature 

Mac OS X 10.8, Apache 2.x, NGiNX, PHP 5.4.x, CodeIgniter 1.7.2/2.1.3

 
Posted: 06 September 2007 04:16 AM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Joined: 2007-03-09
7 posts

Coolfactor, thank you very much for your support. Unfortunately, changing the code as suggested didn’t solve the problem. Is there a PHP setting which can prevent corret variable passing?