Page 1 of 1
Non-static error
Posted: Tue Feb 22, 2011 6:41 am
by gazzieh
Hi
I have seen this around but cannot find a direct solution to this issue.
I have the following code line:
Code: Select all
$settings = DataSettings::getSettings();
This is based upon a class DataSettings and is obviously getting the database connection values from the function getSettings.
I understand that PHP5 (my new test server installation) is the reason for this error and that I could potentially declare the function as static but I get the sense that this is a poor solution.
I have seen recommendations to replace :: with = but this clearly makes no sense with my code line above.
So, how best to make my old code PHP5 compatible?
Re: Non-static error
Posted: Tue Feb 22, 2011 6:43 am
by Weirdan
If the method is static declare it as such.
Re: Non-static error
Posted: Tue Feb 22, 2011 7:17 am
by gazzieh
Yeah, okay. Dumb question with obvious answer.
I now encounter a new issue.
I have a series of $_GET statements that have been running fine under PHP4 but again under PHP5 I am getting an error.
The fact is that the $_GET statements all react to a $_GET statement but works on the principle that if they are not present then the code will simply be missed.
So, I have, for example...
Yet, if 'action' does not exist then the usual reaction is for the code to be ignored. However, I am now getting the following error:
Notice: Undefined index: action in [LOCATION]\index.php on line 15
So, aside from always adding in a catchall statement (combining the above code with a check for existence), which would be messy I am unsure if there is a work around or if the error I have is not an actual PHP5 error but something related to the previous error (though I cannot see any connection).
Re: Non-static error
Posted: Tue Feb 22, 2011 7:23 am
by Weirdan
Re: Non-static error
Posted: Tue Feb 22, 2011 10:47 am
by gazzieh
Sorry Weirdan but this makes no sense to me.
I have a switch command that seems currently to fail due to the non-existence of the variable defined by the $_GET statement. I have no issues with this working on the production copy (under PHP4), which responds as I would expect it to; if the $_GET value is not defined then do the DEFAULT setting.
So, I simply need to know if this has changed within PHP5 and if so, what the work around is. I am assuming I am not the only person who has encountered this and could do with direction and advice. Sorry, but your link offers me no assistance.

(
Re: Non-static error
Posted: Tue Feb 22, 2011 11:22 am
by Weirdan
gazzieh wrote:So, I simply need to know if this has changed within PHP5
No, it was considered error (E_NOTICE) even in PHP4. What could be different though is php settings on your two hosts.
Re: Non-static error
Posted: Tue Feb 22, 2011 11:33 am
by gazzieh
Yeah, I am beginning to realise that what I perceived as basic logic was in fact sloppy programming.
I am being told that the best solution is to test for the variable with isset(), which means messy code for if statements and preceeding code for switches until I can rebuild the code. Oh, how much fun!
Anyhow, I have to recode for HTML 5 at some stage so may as well add this to the developmental plan.
Thanks for the help.