Jump to content

PHP 7.2 password_hash doesn't work


CelticDesigner88

Recommended Posts

I've been puzzling over this all morning. No matter what I do i keep getting these errors:

Quote

[01-Oct-2019 21:45:32 UTC] PHP Warning:  Use of undefined constant  PASSWORD_BCRYPT - assumed ' PASSWORD_BCRYPT' (this will throw an Error in a future version of PHP) in /home/ijwe4nfwf9ei/public_html/blog-approval.php on line 7
[01-Oct-2019 21:45:32 UTC] PHP Warning:  password_hash() expects parameter 2 to be integer, string given in /home/ijwe4nfwf9ei/public_html/blog-approval.php on line 7[01-Oct-2019 22:18:20 UTC] PHP Warning:  Use of undefined constant  PASSWORD_BCRYPT - assumed ' PASSWORD_BCRYPT' (this will throw an Error in a future version of PHP) in /home/ijwe4nfwf9ei/public_html/blog-approval.php on line 3
[01-Oct-2019 22:18:20 UTC] PHP Warning:  password_hash() expects parameter 2 to be integer, string given in /home/ijwe4nfwf9ei/public_html/blog-approval.php on j 3[01-Oct-2019 22:21:44 UTC] PHP Warning:  Use of undefined constant  PASSWORD_BCRYPT - assumed ' PASSWORD_BCRYPT' (this will throw an Error in a future version of PHP) in /home/ijwe4nfwf9ei/public_html/tester.php on line 3
[01-Oct-2019 22:21:44 UTC] PHP Warning:  password_hash() expects parameter 2 to be integer, string given in /home/ijwe4nfwf9ei/public_html/tester.php on line 3

Here's my code: 

<?php
echo phpinfo();
$pass=password_hash ("password", PASSWORD_BCRYPT);
?>

I checked and I'm using php 7, so why do I keep getting this error?

I had it print out my php info so I could check..

https://pyro-creations.com/tester.php

I even read the manual and tried the examples and I still get those errors. How can I fix this?

[please use code tags.]

Link to comment
Share on other sites

Oops! I moved it from blog-approval to tester because I don't need that file anymore. I guess forgot to update it but the error doesn't show in the screen. I grabbed that from the error_log. I also changed that code since to use MD5 in the blog-approval (just to test it), which is fine for what I needed that for but eventually I will need to use password_hash too.

 

Here's what the error log currently says:

[01-Oct-2019 23:13:08 UTC] PHP Warning:  Use of undefined constant  PASSWORD_BCRYPT - assumed ' PASSWORD_BCRYPT' (this will throw an Error in a future version of PHP) in /home/ijwe4nfwf9ei/public_html/tester.php on line 3
[01-Oct-2019 23:13:08 UTC] PHP Warning:  password_hash() expects parameter 2 to be integer, string given in /home/ijwe4nfwf9ei/public_html/tester.php on line 3
[01-Oct-2019 23:20:21 UTC] PHP Warning:  Use of undefined constant  PASSWORD_BCRYPT - assumed ' PASSWORD_BCRYPT' (this will throw an Error in a future version of PHP) in /home/ijwe4nfwf9ei/public_html/tester.php on line 3
[01-Oct-2019 23:20:21 UTC] PHP Warning:  password_hash() expects parameter 2 to be integer, string given in /home/ijwe4nfwf9ei/public_html/tester.php on line 3
[02-Oct-2019 00:31:35 UTC] PHP Warning:  Use of undefined constant  PASSWORD_BCRYPT - assumed ' PASSWORD_BCRYPT' (this will throw an Error in a future version of PHP) in /home/ijwe4nfwf9ei/public_html/tester.php on line 3
[02-Oct-2019 00:31:35 UTC] PHP Warning:  password_hash() expects parameter 2 to be integer, string given in /home/ijwe4nfwf9ei/public_html/tester.php on line 3
[02-Oct-2019 00:32:16 UTC] PHP Warning:  Use of undefined constant  PASSWORD_BCRYPT - assumed ' PASSWORD_BCRYPT' (this will throw an Error in a future version of PHP) in /home/ijwe4nfwf9ei/public_html/tester.php on line 3
[02-Oct-2019 00:32:16 UTC] PHP Warning:  password_hash() expects parameter 2 to be integer, string given in /home/ijwe4nfwf9ei/public_html/tester.php on line 3
 

And the tester with that added echo:

<?php
echo phpinfo();
$pass=password_hash ("password", PASSWORD_BCRYPT);
echo $pass;
?>

Edited by CelticDesigner88
Link to comment
Share on other sites

how did you arrive at this point? did this code work before? did you copy/paste the PASSWORD_BCRYPT value from somewhere or did you type it manually?

if you copied it, i recommend that you delete it and manually type it. we have seen cases where 'published' code contains non-ascii or non-printing characters, which looks correct, but which php cannot recognize.

Edited by mac_gyver
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.