Twitch stream updates

Hello Fugiman thanks for your reply. The problem persists. The code i have at the moment is:

<?php

include("_mysql.php");

$mysqli = new mysqli($host, $user, $pwd, $db);

$streams=$mysqli->query("SELECT * FROM ".PREFIX."streams");
while($ds=$streams->fetch_assoc()) {
	
	$streamID = $ds['streamID'];
	$channel = $ds['channel'];
	$type = $ds['type'];
	
	switch($type) {
		
		case 1: // Twitch Stream API
			$twitch_api = 'https://api.twitch.tv/kraken/streams/'.$channel;
			$twitch_xml = json_decode(@file_get_contents($twitch_api));
		    $viewers = $twitch_xml->stream->channel_count;
		    $thumb = $twitch_xml->stream->channel->screen_cap_url_large;
		    if($twitch_xml->stream->stream_type == 'live') $live = 1;
		    else $live = 0;
		break;
                default:
		break;
		
		}
	
	$query = "UPDATE ".PREFIX."streams SET status='".$live."', viewers='".$viewers."', thumb='".$thumb."' WHERE streamID='".$streamID."'";
	$result=$mysqli->query($query);
}
$mysqli->close;
?>

Don’t know whats wrong hope you can help me