enter image description here When you try to register, the following error occurs:

Warning: Illegal string offset 'user_login' in .... \ db_register.php on line 32

In this case, the record in the database occurs in the correct form!

Registration File:

<?php require_once 'include/db_functions.php'; $db = new db_functions(); // json response array $response = array("error" => FALSE); if (isset($_POST['user_login']) && isset($_POST['user_password']) && isset($_POST['user_name']) && isset($_POST['user_middle_name']) && isset($_POST['user_last_name']) && isset($_POST['user_group'])) { // receiving the post params $user_login = $_POST['user_login']; $password = $_POST['user_password']; $user_name = $_POST['user_name']; $user_middle_name = $_POST['user_middle_name']; $user_last_name = $_POST['user_last_name']; $user_group = $_POST['user_group']; // check if user is already existed with the same login if ($db->isUserExisted($user_login)) { // user already existed $response["error"] = TRUE; $response["error_msg"] = "User " . $user_login . " already exists"; echo json_encode($response); } else { // create a new user $user = $db->storeUser($user_login, $password, $user_name, $user_middle_name, $user_last_name, $user_group); if ($user) { **袨楔袠袘袣袗 袩袪袨袠小啸袨袛袠孝 袟袛袝小鞋, 袙袨 袙小袝啸 小袥袝袛校挟些袠啸 袩袨袥携啸 $response** $response["error"] = FALSE; $response["uid"] = $user["user_uniqueid"]; $response["user"]["user_login"] = $user["user_login"]; $response["user"]["user_name"] = $user["user_name"]; $response["user"]["user_middle_name"] = $user["user_middle_name"]; $response["user"]["created_at"] = $user["created_at"]; echo json_encode($response); } else { // user failed to store $response["error"] = TRUE; $response["error_msg"] = "Failed to store"; echo json_encode($response); } } } else { $response["error"] = TRUE; $response["error_msg"] = "Fill up all fields!"; echo json_encode($response); } ?> 
  • one
    $ user ["user_login"] - have you tried debugging? This error occurs when you are accessing a non-existent array field. - Jurij Jazdanov
  • I agree with the previous speaker! :) Look through var_dump ($ user), what you have displayed there ... maybe you have $ user - this is an object, and you need to access its properties like this: $ user-> user_login, or maybe $ user - this an array with nested arrays, and you need to address it like this: $ user [0] ['user_login'] ... these are the most obvious options, in fact it can be null or [] (empty array) if this username is in the database no, or an array of objects ... in short, debugging first, and if there is anything supernatural at all, then go back and ask the question more thoroughly :) - Stanislav

0