maximum execution time of 30 seconds exceeded php
<p>When I run my script I receive the following error before processing all rows of data.</p>

<blockquote>
  <p>maximum execution time of 30 seconds
  exceeded</p>
</blockquote>

<p>After researching the problem, I <em>should</em> be able to extend the max_execution_time time which <em>should</em> resolve the problem.</p>

<p>But being in my PHP programming infancy I would like to know if there is a more optimal way of doing my script below, so I do not have to rely on "get out of jail cards". </p>

<p>The script is:</p>

<p>1 Taking a CSV file</p>

<p>2 Cherry picking some columns</p>

<p>3 Trying to insert 10k rows of CSV data into a my SQL table</p>

<p>In my head I think I should be able to insert in chunks, but that is so far beyond my skillset I do not even know how to write one line :\</p>

<p>Many thanks in advance</p>

<pre><code>&lt;?php
function processCSV()
{
    global $uploadFile;
    include 'dbConnection.inc.php';
    dbConnection("xx","xx","xx");
    $rowCounter = 0;
    $loadLocationCsvUrl = fopen($uploadFile,"r");   
    if ($loadLocationCsvUrl &lt;&gt; false)
    {
        while ($locationFile = fgetcsv($loadLocationCsvUrl, ','))
        {
            $officeId = $locationFile[2];
            $country = $locationFile[9];
            $country = trim($country);
            $country = htmlspecialchars($country);
            $open = $locationFile[4];
            $open = trim($open);
            $open = htmlspecialchars($open);
            $insString = "insert into countrytable set officeId='$officeId', countryname='$country', status='$open'";
                switch($country)
                {
                    case $country &lt;&gt; 'Country':
                        if (!mysql_query($insString))
                        {
                            echo "&lt;p&gt;error " . mysql_error() . "&lt;/p&gt;";    
                        }
                        break;
                }
            $rowCounter++;
        }
        echo "$rowCounter inserted.";
    }
    fclose($loadLocationCsvUrl);
}
processCSV();
?&gt;
</code></pre>
