I'm trying to get records from a table and write to another of the same type, but I'm having this error:
There are no more rows in the active result set. Since this result set is not scrollable, no more data may be retrieved.
The code is as follows
$gameuser = $pdo->prepare('SELECT * FROM [omegashop].[dbo].[GameUser] WHERE [token] = :token');
$gameuser->bindParam(':token', $token, PDO::PARAM_STR);
$gameuser->execute();
$result = $gameuser->fetchAll();
foreach($result as $linha)
{
$usuario = $linha['userid'];
$senha = $linha['Passwd'];
$remote = 0;
$query = $pdo->prepare("INSERT INTO [accountdb].[dbo].[".( strtoupper($usuario[0]) ) ."GameUser] ([userid],[Passwd],[GPCode],[RegistDay],[DisuseDay],[inuse],[Grade],[EventChk],[SelectChk],[BlockChk],[SpecialChk],[Credit],[DelChk],[Channel]) values( :usuario, :senha,'PTP-RUD001','12-12-2020','12-12-2020','0','U','0','0','0','0','0','0', :remote)");
$query->bindParam(':usuario', $usuario, PDO::PARAM_STR);
$query->bindParam(':senha', $senha, PDO::PARAM_STR);
$query->bindParam(':remote', $remote, PDO::PARAM_STR);
$query->execute();
}'