14

I'm about to open my website when I noticed that one of my mods gives me this error:

Fatal error: Cannot use object of type mysqli_result as array in /var/www/vbsubscribetouser.php on line 303

I've went to line 303 and this is what I found:

$followingdata = mysqli_query($mysqli, /* ... */);

//Check if requested username can be followed.
if (in_array($followingdata['usergroupid'], explode("|", $vbulletin->options['subscribetouser_usergroups_cannot']))){

1 Answer 1

37

Cannot use object of type mysqli_result as array

Use mysqli_fetch_assoc or mysqli_fetch_array to fetch a result row as an associative array.

$query = "SELECT 1";
$result = $mysqli->query($query);
$followingdata = $result->fetch_assoc()

or

$followingdata = $result->fetch_array(MYSQLI_ASSOC);
Sign up to request clarification or add additional context in comments.

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.