title: insert data from a csv file into sql server database using php
body: <p>I am getting an error while inserting although my filename and location are properly set..Any solution?
  Thanks in advance...Here are my codes:</p>
  
  <pre><code>// path where your CSV file is located
  define('CSV_PATH','C:\xampp\htdocs\form');
  
  // Name of your CSV file
  $csv_file = CSV_PATH . "test.csv"; 
  
  
  if (($handle = fopen($csv_file, "r")) !== FALSE) {
     fgetcsv($handle);   
     while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
          $num = count($data);
          for ($c=0; $c &lt; $num; $c++) {
            $col[$c] = $data[$c];
          }
  
   $col1 = $col[0];
   $col2 = $col[1];
   $col3 = $col[2];
  
   $query = "INSERT INTO csvTable(ID,Name,city) VALUES ('".$col1."','".$col2."','".$col3."')";
   $params = array();
   $options =  array( "Scrollable" =&gt; SQLSRV_CURSOR_KEYSET );
   $stmt = sqlsrv_query($conn, $query, $params, $options ); 
   }
      fclose($handle);
   }
  
  echo "File data successfully imported to database!!";
  //mysql_close($connect);
  ?&gt;
  </code></pre>
  
  <blockquote>
    <p>Error Message: Warning: fopen(C:\xampp\htdocs\formtest.csv): failed to
    open stream: No such file or directory in
    C:\xampp\htdocs\form\upload.php on line 15</p>
  </blockquote>