The error is that I am trying to convert an object into a string and cannot figure out how to do it right.
Here is my code:
users.php public function create(){ global $database; $sql = "INSERT INTO users(username , password , first_name , last_name) VALUES ('$database->$this->username','$database->$this->password','$database->$this->first_name','$database->$this->last_name')"; if($database->query($sql)) { $this->id = $database->insert_id(); return true; } else { return false; } } and in the test falye I try to substitute the data:
test.php <?php require_once('../../includes/initialize.php'); if (!$session->is_logged_in()) { redirect_to("login.php"); } include_layout_template('admin_header.php'); $user = new Users(); $user->username = "ValeraTkachenko"; $user->password = "1111"; $user->first_name = "Valera"; $user->last_name = "Tkachenko"; $user->create(); include_layout_template('admin_footer.php'); The error occurs at the moment VALUES ('$database->$this->username'... that I am trying to convert the object to a string. Tell me, please, how can I fix it. Thank you
->$thisyou are using incorrectly - splash58