rendered paste body<?php # Insert additional items and goodies $PID = 15; require(sqlarrays.php); # $itemquery['3']['0'] = "INSERT INTO Item (PID, IID, [Index], Prefix, Info, Num, MaxEnd, CurEnd, SetGem, XAttack, XMagic, XDefense, XHit, XDodge, Protect, UpgrLevel, UpgrRate) VALUES ('" . $PID . "', '" . $IID . "', '251', '0', '1', '1', '24', '24', '0', '0', '0', '0', '0', '0', '0', '0', '0')"; # $itemquery['3']['1'] = "INSERT INTO Item (PID, IID, [Index], Prefix, Info, Num, MaxEnd, CurEnd, SetGem, XAttack, XMagic, XDefense, XHit, XDodge, Protect, UpgrLevel, UpgrRate) VALUES ('" . $PID . "', '" . $IID . "', '252', '0', '1', '1', '14', '14', '0', '0', '0', '0', '0', '0', '0', '0', '0')"; # $itemquery['3']['2'] = "INSERT INTO Item (PID, IID, [Index], Prefix, Info, Num, MaxEnd, CurEnd, SetGem, XAttack, XMagic, XDefense, XHit, XDodge, Protect, UpgrLevel, UpgrRate) VALUES ('" . $PID . "', '" . $IID . "', '253', '0', '1', '1', '10', '10', '0', '0', '0', '0', '0', '0', '0', '0', '0')"; # $itemquery['3']['3'] = "INSERT INTO Item (PID, IID, [Index], Prefix, Info, Num, MaxEnd, CurEnd, SetGem, XAttack, XMagic, XDefense, XHit, XDodge, Protect, UpgrLevel, UpgrRate) VALUES ('" . $PID . "', '" . $IID . "', '254', '0', '1', '1', '12', '12', '0', '0', '0', '0', '0', '0', '0', '0', '0')"; $query = "SELECT TOP 1 IID FROM [Item] ORDER BY IID DESC"; $result = mssql_query($query); $row = mssql_fetch_array($result); $IID = $row['IID'] + 1; echo $IID; // returns 107 foreach($itemquery['3'] as $query) { // 3=Global $result = mssql_query($query); $IID = $IID + 1; echo $IID; // returns 108, 109, etc. echo $query . "<br>"; // returns the correct query but with missing $IID # 320321INSERT INTO Item (PID, IID, [Index], Prefix, Info, Num, MaxEnd, CurEnd, SetGem, XAttack, XMagic, XDefense, XHit, XDodge, Protect, UpgrLevel, UpgrRate) VALUES ('15', '', '192', '0', '0', '100', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0') # Note the missing IID section, just says '', }?>