DEV Community

Mark John Mejias
Mark John Mejias

Posted on

Trying to get property ‘error’ of non-object in register.php on line 41

Notice: Trying to get property ‘username’ of non-object in C:\xampp\htdocs\mobile\login_register\register.php on line 25

Notice: Trying to get property ‘userpass’ of non-object in C:\xampp\htdocs\mobile\login_register\register.php on line 26

Notice: Trying to get property ‘mobile’ of non-object in C:\xampp\htdocs\mobile\login_register\register.php on line 27

Notice: Trying to get property ‘email’ of non-object in C:\xampp\htdocs\mobile\login_register\register.php on line 28

Notice: Trying to get property ‘error’ of non-object in C:\xampp\htdocs\mobile\login_register\register.php on line 41 "Error: INSERT INTO users (username, userpass, mobile, email) VALUES (’’, ‘’, ‘’, ‘’) "

register.php

require "dbconnect.php";

$data = file_get_contents("php://input");
if (isset($data)) {
    $request = json_decode($data);
 line 25   $username = $request->username;
 line 26   $userpass = $request->userpass;
 line 27   $mobile = $request->mobile;
 line 28   $email = $request->email;

}

$username = stripslashes($username);
$userpass = stripslashes($userpass);
$sql = "INSERT INTO users (username, userpass, mobile, email) VALUES                 ('$username', '$userpass', '$mobile', '$email')";

if ($con->query($sql) === TRUE) {
$response= "Registration successfull";

} else {
  line 41  $response= "Error: " . $sql . "<br>" . $db->error;
}
    echo json_encode($response);

dbconnect.php

<?php
define('HOST','localhost');
define('USER','root');
define('PASS','');
define('DB', '8990qacheck');

$con = mysqli_connect(HOST,USER,PASS,DB);
if (!$con){
die("Error in connection" . mysqli_connect_error()) ;
}
?>

the problem is just here its no worth showing the ts file

Top comments (0)