CelticDesigner88 Posted October 1, 2019 Share Posted October 1, 2019 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.] Quote Link to comment https://forums.phpfreaks.com/topic/309316-php-72-password_hash-doesnt-work/ Share on other sites More sharing options...
benanamen Posted October 1, 2019 Share Posted October 1, 2019 (edited) What is the code from blog-approval.php? The tester is not displaying the error you posted. It is displaying a 1 as it should. If you echo'ed the line in your tester you would see a hash. Also, phpinfo() does not require echo. Edited October 1, 2019 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/309316-php-72-password_hash-doesnt-work/#findComment-1570199 Share on other sites More sharing options...
CelticDesigner88 Posted October 2, 2019 Author Share Posted October 2, 2019 (edited) 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 October 2, 2019 by CelticDesigner88 Quote Link to comment https://forums.phpfreaks.com/topic/309316-php-72-password_hash-doesnt-work/#findComment-1570200 Share on other sites More sharing options...
mac_gyver Posted October 2, 2019 Share Posted October 2, 2019 (edited) 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 October 2, 2019 by mac_gyver Quote Link to comment https://forums.phpfreaks.com/topic/309316-php-72-password_hash-doesnt-work/#findComment-1570202 Share on other sites More sharing options...
CelticDesigner88 Posted October 2, 2019 Author Share Posted October 2, 2019 I copied it.. I'm almost positive I copied it from here: https://www.php.net/manual/en/function.password-hash.php That's interesting.. I think I've actually run into that before too. I'll try rewriting it. Quote Link to comment https://forums.phpfreaks.com/topic/309316-php-72-password_hash-doesnt-work/#findComment-1570203 Share on other sites More sharing options...
CelticDesigner88 Posted October 2, 2019 Author Share Posted October 2, 2019 Nope still throwing that error. Quote Link to comment https://forums.phpfreaks.com/topic/309316-php-72-password_hash-doesnt-work/#findComment-1570204 Share on other sites More sharing options...
requinix Posted October 2, 2019 Share Posted October 2, 2019 PASSWORD_BCRYPT is available in core PHP since before 7.0. Your phpinfo page doesn't seem to be working... Quote Link to comment https://forums.phpfreaks.com/topic/309316-php-72-password_hash-doesnt-work/#findComment-1570206 Share on other sites More sharing options...
CelticDesigner88 Posted October 2, 2019 Author Share Posted October 2, 2019 Nevermind! I guess I copied more than I thought. It's working now, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/309316-php-72-password_hash-doesnt-work/#findComment-1570207 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.