MySql记录插入在181822行停止

I used the Following php code to Generate 8000000 Random Strings each with length of 25 Characters;

<?php
require('rsources/conn/config.php'); //Config File Contains the Connection Paramters
ini_set('max_execution_time', 3600);
?>
<html>
<body>
<head>
<title>Code Generator</title>
</head>
<?php
function generateRandomString($length = 25) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomString;
}

    for ($i = 0; $i < 8000000; $i++) {
        $newcode = generateRandomString();
        $sql = "INSERT INTO ftbl_codes (sid, code, is_active, used_by) SELECT IFNULL(MAX(sid)+1,1), '" . $newcode . "', '1', '' FROM ftbl_codes;";
        //echo generateRandomString() . "<br />";
        $result = mysql_query($sql,$connection);
        if ($result){
            echo '<b><font style="color:yellow;background-color:Green;">' . $i . ' : Code Generation Succeeded</font></b> : ' . $newcode . "<br />";
        }else{
            echo '<b><font style="color:red;background-color:black;">' . $i . ' : Code Generation FAILED</font></b> : ' . $newcode . " " . mysql_error() . "<br />";
        }
    }
?>
</body>
</html>

It Should Generate the Codes to be inserted into the table;

CREATE TABLE `ftbl_codes` (
  `sid` bigint(20) NOT NULL,
  `code` varchar(25) NOT NULL,
  `is_active` tinyint(1) NOT NULL,
  `used_by` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

I am using Xampp, Server version: 10.1.31-MariaDB. The Insertion works fine untill the $i Reaches 181822. Can you Help me understand where the problem is.