title: How to insert text file to database table mysql
body: <p>I have a batchcode.txt which contains list of batch code.</p>
  
  <pre><code>645863
  302422
  430307
  821773
  599738
  671768
  732159
  </code></pre>
  
  <p>and so on</p>
  
  <p>I have a table in my database which is called batchcode with fields 'id','batchcode'.</p>
  
  <p>My problem is it wont insert my text file into my table called batchcode. I already did the import and select table but nothing works...</p>
  
  <p>I need some help can anyone help me please.</p>
  
  <pre><code>&lt;?php
  $host= "localhost";
  $user= "root";
  $pass= "";
  $db="klayton";
  
  $connect= mysql_connect($host,$user,$pass);
  if (!$connect)die ("Cannot connect!");
  mysql_select_db($db, $connect);
  
  $file = fopen("batchcode.txt","r");  
  
  while(! feof($file))
  {
  $sql = "INSERT INTO batchcode( batchcode ) VALUES ('fgets($file)')"; //Insert every read line from txt to mysql database
  mysql_query($sql);
  }
  fclose($file);
  ?&gt;
  </code></pre>
  
  <p>I got an error that says "Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\test\index.php on line 22"</p>