Glindet Posted October 14, 2021 Share Posted October 14, 2021 hello pls i have been facing this error for days now . can someone help me to fix it. the bold line is the one having the warning message. if($answer["username"] == $_POST["loginUser"] && $answer["password"] == $encryptpass) { $_SESSION["loggedIn"] = "ok"; $_SESSION["id"] = $answer["id"]; $_SESSION["name"] = $answer["name"]; $_SESSION["username"] = $answer["username"]; $_SESSION["picture"] = $answer["picture"]; $_SESSION["profile"] = $answer["profile"]; echo '<script> window.location = "home"; </script>'; } else { echo '<br><div class="alert alert-danger">User or password incorrect</div>'; } Quote Link to comment https://forums.phpfreaks.com/topic/313983-warning-trying-to-access-array-offset-on-value-of-type-bool-in-cxampphtdocspos-system2-user-modulecontrollersuserscontrollerphp-on-line-29/ Share on other sites More sharing options...
ginerjm Posted October 14, 2021 Share Posted October 14, 2021 From what I can see I doubt that the answer[password] value will ever be equal to an encrypted password. I"m assuming that the answer array is coming from the user's input? Quote Link to comment https://forums.phpfreaks.com/topic/313983-warning-trying-to-access-array-offset-on-value-of-type-bool-in-cxampphtdocspos-system2-user-modulecontrollersuserscontrollerphp-on-line-29/#findComment-1591014 Share on other sites More sharing options...
requinix Posted October 14, 2021 Share Posted October 14, 2021 The error is complaining that you're trying to treat a boolean value as if it were an array. There are two variables on that line. One of them is $_POST. I really hope you don't have code that somehow turns it into a boolean. The other variable is $answer... Quote Link to comment https://forums.phpfreaks.com/topic/313983-warning-trying-to-access-array-offset-on-value-of-type-bool-in-cxampphtdocspos-system2-user-modulecontrollersuserscontrollerphp-on-line-29/#findComment-1591019 Share on other sites More sharing options...
Barand Posted October 14, 2021 Share Posted October 14, 2021 My money's on $answer being a query result and the query has an error. Quote Link to comment https://forums.phpfreaks.com/topic/313983-warning-trying-to-access-array-offset-on-value-of-type-bool-in-cxampphtdocspos-system2-user-modulecontrollersuserscontrollerphp-on-line-29/#findComment-1591029 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.