peacehunter Posted January 1, 2011 Share Posted January 1, 2011 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 More sharing options...
iwato Posted January 1, 2011 Share Posted January 1, 2011 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 More sharing options...
peacehunter Posted January 1, 2011 Author Share Posted January 1, 2011 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.RoddyThnxxxxxxxx..........The problem is solved........... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.