2013-05-13 26 views
5

Tôi sắp mở trang web của tôi khi tôi nhận thấy rằng một trong những mods của tôi mang lại cho tôi lỗi này:Fatal error: Không thể sử dụng đối tượng của loại mysqli_result

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

Tôi đã đi đến dòng 303 và đây là những gì tôi tìm thấy:

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

Dưới đây là tất cả các mã bắt đầu từ dòng 303:

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

if ($followinginfo[subscribers] > 0){ 
    $user_followers = $followinginfo[followers].$userinfo[userid].'|'; 
} 
else{ 
    $user_followers = '|'.$userinfo[userid].'|'; 
} 

$vbulletin->db->query_write(" 
    UPDATE " . TABLE_PREFIX . "user 
    SET subscribers = subscribers + 1, `followers` = '$user_followers' 
    WHERE userid = $followinginfo[userid] 
"); 

tôi không phải là một chuyên gia trong php mã hóa, do đó, một bi t giúp đỡ sẽ là tuyệt vời trước khi mở trang web. Bất kỳ trợ giúp/đề xuất nào?

Cảm ơn bạn rất nhiều!

Trả lời

20

Cannot use object of type mysqli_result as array

Sử dụng mysqli_fetch_assoc hoặc mysqli_fetch_array để tìm nạp hàng kết quả làm mảng kết hợp.

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

hoặc

$followingdata = $result->fetch_array(MYSQLI_ASSOC); 
+0

Điều đó đã làm nó. Cảm ơn nhiều! Tôi nên bắt đầu học một số php! –

Các vấn đề liên quan