×

Please Login or Register to continue.

3
(1.3K Views)

I am creating a signup form using PHP and MYSQL database. I am getting an error Uncaught TypeError: password_hash(): Argument #3 ($options) must be of type array, null given in C:\xampp\htdocs\form\signup.php:104 Stack trace: #0 C:\xampp\htdocs\form\signup.php(104): password_hash('hello123', '2y', NULL) #1 {main} thrown in PHP. I want to convert simple text to hash pattern using password_hash() function but getting TypeError: password_hash(): Argument #3 ($options) must be of type array, null given error .

I tried PHP code - 

<?php 
password_hash('hello123', '2y', NULL)
?>

Is there any solution to fix it? 

(2.4K Points)
in PHP

Share

2 Answers
(3.4K Points)
(edited)
2

According to this error Uncaught TypeError: password_hash(): Argument #3 ($options) must be of type array, null given you passed third parameter null. This error comes when you pass the third parameter null. According to this error, you cannot pass the third optional parameter as null value. Focus on your error Argument #3 ($options) must be of type array. It's saying the third parameter should be an array type.

$password='admin@123';
    $options = array("cost"=>4);
    $password = password_hash($password,PASSWORD_BCRYPT,$options);

In the solution above I created an array type and pass in the third parameter. You can check reference here - 

Registration and login form in PHP and MYSQL


Comment
The error has been removed. Thank you for your help.
arnabisaha 18 Dec 2021

(9.4K Points)
(edited)
2

The third parameter should be an array type in the password_has() function.
You are passing the Null value in the third parameter. Change it like this -

This is totally wrong way to convert simple text to the hash pattern in PHP -

password_hash('hello123', '2y', NULL)

Change above code like this - 
 

$arr = array("cost"=>4);
password_hash('hello123','PASSWORD_BCRYPT',$arr)


This is the solution of your error Uncaught TypeError: password_hash(): Argument #3 ($options) must be of type array, null given . 


Comment

Related Questions :-

Featured Items:-


Certificate and Marksheet system with verification & Franchise in PHP

$75



Certificate system in PHP website | PHP scripts

$22



Home Credito loan finance management multipurpose system in PHP

$65




Your Answer

You can post your answer after login..

Live Chat

Hello! How can we assist you today?