1

Code:

PHP-Version: 7.4.1

Error Line:

if($this->allianceData['ally_owner'] == $USER['id']) {
2
  • 1
    The error means that your query don't receive a row. then he give a boolean. and you try to access the boolean. You can try this: if($this->allianceData['ally_owner'] ?? 'default value' == $USER['id']) { Commented Jun 12, 2022 at 18:08
  • 1
    The error message simply means that the value of either $this->allianceData OR $USER is a boolean and not an array. No other assumptions can be made from what is provided. Commented Jun 12, 2022 at 19:20

3 Answers 3

1

The error means that your query don't receive a row. then he give a boolean. and you try to access the boolean. You can try this:

if($this->allianceData['ally_owner'] ?? 'default value' == $USER['id'] ?? 'default value') {

Since I don't know your entire code, I assume that you have already checked whether the user is authenticated? Either via middleware or in the code above.

Sign up to request clarification or add additional context in comments.

2 Comments

Since the error doesn't specifies the column, the error can either be on $this->allianceData or $USER
@EliasSoares You are right! I assumed that the questioner had already checked this. but since I don't know the code, this would also be an option to be intercepted at this point. I have added to my answer.
1

It is possible that you are trying to access a value that does not exist in your array, you can try using print_r($this->allianceData); and print_r($USER); to see how the arrangements are composed.

Comments

0

I recently had this problem, the solution for me turned out to be extremely simple and thought I would just note it down to hopefully save someone a bunch of searching for nothing!

If your errors are being displayed in the backend of your site, in a form, on a settings page, this might help you.

Essentially we are requesting an element of an array but in my instance the array was not created yet, I wrote into the fields displaying the error then saved the form. Thus, creating the array, adding the values to the array for future calls. On reload, the page worked!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.