Hint: Indent code by 4 spaces, so it displays properly.
It looks like you are not encoding the get parameters correctly. I am pretty sure there is no reserved variable called $SERVER in PHP. If you meant $_SERVER, this has no QUERYSTRING, but a QUERY_STRING item.
Still you should probably better do something like the following:
$url = "https://api.twitter.com/1.1/search/tweets.json";
$getfield = "?q=" . urlencode($_GET['q']);
$twitter = new TwitterAPIExchange($settings);
echo $twitter->setGetfield($getfield)
->buildOauth($url, 'GET')
->performRequest();