LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-20-2006, 07:16 PM   #1
youreal
LQ Newbie
 
Registered: Feb 2006
Posts: 12

Rep: Reputation: 0
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
 
Old 06-20-2006, 07:45 PM   #2
demon_vox
Member
 
Registered: May 2006
Location: Argentina
Distribution: SuSE 10
Posts: 173

Rep: Reputation: 30
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.
 
Old 06-20-2006, 08:27 PM   #3
youreal
LQ Newbie
 
Registered: Feb 2006
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by demon_vox
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.
$this->hd=mysql_connect($host,$user,$psw)or die("please try again later !");
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??
 
Old 06-20-2006, 08:40 PM   #4
demon_vox
Member
 
Registered: May 2006
Location: Argentina
Distribution: SuSE 10
Posts: 173

Rep: Reputation: 30
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!
 
Old 06-20-2006, 09:09 PM   #5
youreal
LQ Newbie
 
Registered: Feb 2006
Posts: 12

Original Poster
Rep: Reputation: 0
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

Last edited by youreal; 06-20-2006 at 09:11 PM.
 
Old 06-20-2006, 09:33 PM   #6
youreal
LQ Newbie
 
Registered: Feb 2006
Posts: 12

Original Poster
Rep: Reputation: 0
I did it as your said, replace it by $hd and now it work well as before.
3X!!!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Probleme with makefile os2 Programming 1 06-07-2005 02:03 PM
Probleme with thunderbird acvatiq Linux - Software 1 04-22-2005 02:08 PM
Probleme to erase a file os2 Programming 2 02-15-2005 03:17 PM
gIFT probleme princeware Slackware 2 06-15-2004 01:19 AM
xinetd probleme kemu Linux - Networking 2 08-13-2003 02:14 PM


All times are GMT -5. The time now is 01:23 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration