Solution TechnoDiver Posted September 7, 2021 Solution Share Posted September 7, 2021 Hi, Phreaks, I'm stuck on something that maybe someone can help with on trying to send a user information to phpmyadmin I get this error -> Quote SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\xD8,\x08Up\x92...' for column `qcic`.`users`.`salt` at row 1 There's 2 problems here, as you can see. 1) I've got an invalid datetime format. 2) is obviously the incorrect string value on my salt value. here is the corresponding code -> <?php if($validation->passed()) { $user = new User(); $salt = Hash::salt(32); try { $user->create(array( "username" => Input::get("usernane"), "password" => Hash::make(Input::get("password"), $salt), "email" => Input::get("email"), "salt" => $salt, "signup_date" => date_create('now')->format('Y-m-d H:i:s'), "role" => 2, )); $sent = true; } catch(Exception $e) { die($e->getMessage()); } } else { $errors = $validation->errors(); } It can be seen how I did both of them here. Additionally the Hash::salt method is here -> <?php public static function salt($length) { return random_bytes($length); } the column 'signup_date' is in my database as a datetime not null with 'none' as default. The column 'salt' is a VARCHAR(32) not null, 'none' as default Can anyone help me out with what I've done wrong, please. TIA Quote Link to comment https://forums.phpfreaks.com/topic/313677-incorrect-string-type/ Share on other sites More sharing options...
TechnoDiver Posted September 7, 2021 Author Share Posted September 7, 2021 Switching from hash() to password_hash() and not using a salt resolved both issues. Question though, does password_hash() also salt the hash or is that something I should still do?? Quote Link to comment https://forums.phpfreaks.com/topic/313677-incorrect-string-type/#findComment-1589708 Share on other sites More sharing options...
requinix Posted September 7, 2021 Share Posted September 7, 2021 The password_* functions handle everything for you. 1 Quote Link to comment https://forums.phpfreaks.com/topic/313677-incorrect-string-type/#findComment-1589709 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.