Probleme with my programme
After i installed the php5,when i running my programme
will have a error as follow: Fatal error: Using $this when not in object context in /home/cityleft/regmail/1mysql.php on line 13 any body know this? how can i fix it? thanx |
Hi,
its very simple, you are using $this when you are not in an object context. $this represents an instance of your object, so, for example, it doesnt have a meaning if you use it in a static method. If you can post just the code where it fails maybe we can guess some more. Greetings. |
Quote:
mysql_select_db($name, $this->hd ) or die ("please try again later !"); As above $this will appear error,i am sure that the programme is no problem,because it running ok for many months! Since upgrade php to php5,the programme will make a mistake ,it's made me so confuse,I searched all the web about the problem,somebody said it's a bug in the pear,isn't it?? |
Hi,
and where is this code in? if it just in the "main" part or in a function it will be wrong. If you use $this you must put it in the code of a method. Be careful because many thing that PHP4 allowed are no longer allowed in PHP5, but are rightfully disallowed :) (there are good reason for it). If you are just using $this->hd and you dont have another thing using $this, you could just replace it by $hd and it should work. But whats important to know if you are using an object or not. Greetings! |
Thanks a lot first~
yes,you are right.This code is in a function,maybe you are right! ok,let me check it more times thanx again |
I did it as your said, replace it by $hd and now it work well as before.
3X!!! |
All times are GMT -5. The time now is 02:47 PM. |