Should that not echo game id?
$gameName = htmlspecialchars($_POST['name1']);
$getGameID = 'https://api.twitch.tv/helix/games?game_name=';
$clientId = 'xxx';
$ch = curl_init();
$apiVers = '&api_version=5';
curl_setopt_array($ch2, array(
CURLOPT_HTTPHEADER => array(
'Client-ID: ' . $clientId
),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $getGameID . $gameName . $apiVers
));
$response2 = curl_exec($ch2);
$resp = json_decode($response2);
$gameID = $resp->data[0]->game_id;