Jump to content

Need help about php class


peacehunter

Recommended Posts

Recently I am working with a php class, but I am receiving an error message like this :\

 Fatal error: Using $this when not in object context in C:\wamp\www\social network\class\reg_data.class.php on line 10

although I didn't find any error on my code.My code is (file name is: reg_data.class.php):

  <?phprequire("config.php");class reg_data{   var $query;	var $id;   	var $first_name;	var $last_name; 	function reg($email){		$this->query=mysql_query("SELECT * FROM reg WHERE email='$email'");		$row=mysql_fetch_array($this->query);		$this->id=$row['id'];		$this->first_name=$row['first_name'];		$this->last_name=$row['last_name'];			}		}?>

I could not understand that where is wrong. Plzzzz give me an solution about this problem.

Link to comment
Share on other sites

Recently I am working with a php class, but I am receiving an error message like this :\
 Fatal error: Using $this when not in object context in C:\wamp\www\social network\class\reg_data.class.php on line 10

I could not understand that where is wrong. Plzzzz give me an solution about this problem.

Is this the totality of your class?For, if it is, I see no provision for reading the value of $email into your reg() method. You need a __construct() method that would make $email an admissible parameter when your object is initialized.Roddy
Link to comment
Share on other sites

Is this the totality of your class?For, if it is, I see no provision for reading the value of $email into your reg() method. You need a __construct() method that would make $email an admissible parameter when your object is initialized.Roddy
Thnxxxxxxxx..........The problem is solved...........
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...