0

I have php class in my project for login and registration, how to include that class in my registration.php file and create object, when i include by include function than this error is occured Parse error: syntax error, unexpected T_OBJECT_OPERATOR in C:\wamp\www\loginoops\user1.php on line 9, Please help me. Code id below-

<?php 
include_once("connection.php");
class User1{
public $username=null;
public $password=null;
public $mobile=null;
public $email=null;
public function _construct($data=array()){
if(isset($data['name'])){this->$username=stripcslashes(strip_tags($data['name']));
}
if(isset($data['pass'])){this->$password=stripcslashes(strip_tags($data['pass']));}
if(isset($data['mobile'])){this->$mobile=stripcslashes(strip_tags($data['mobile']));}
if(isset($data['email'])){this->$password=stripcslashes(strip_tags($data['email']));}

}
public function storeFormValue($param){
this->_construct($param);
}
public function regUser($con){
$success=null;
try{
$sql="insert into user        values('".$username."','".$password."','".$mobile."','".$email."')";
if(mysqli_query($con,$sql)
{
return "Registration Successful <br/> <a href='Register.php'>Login Now</a>";

}


}
catch(Exception $e)
{
return  $e->getMessage();
}

}

}
?>
3

1 Answer 1

1

You need to use $this instead of this and $this->username instead of this->$username.

Sign up to request clarification or add additional context in comments.

9 Comments

this error occurred Fatal error: Cannot access empty property in C:\wamp\www\loginoops\user1.php on line 9
@Ravi Remove the dollar sign before property name, it should be like $this->username.
Warning: mysqli_query() expects parameter 1 to be mysqli, array given in C:\wamp\www\loginoops\user1.php on line 23
if i use mysqli_query($con,$sql) then Warning: mysqli_query() expects parameter 1 to be mysqli, array given in C:\wamp\www\loginoops\user1.php on line 23 is come, if use mysql_query then warning is not come but in both cash data is not inserted to database.
Do you use mysql or mysqli?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.