Hi everyone,
I have the following code and it works just great the way it is, but I want to start reading the text file from the second line rather than the first. I this possible?
After searching the forums I played with fseek() for a while with no success. Would fseek() be the best thing? Any guidance would be greatly appreciated.
Thanks in advance!
set_include_path('../PEAR' . PATH_SEPARATOR
. get_include_path());
ini_set('display_errors', 1);
error_reporting(E_ALL);
// Load PEAR DB
require_once("../PEAR/PEAR.php");
require_once("../PEAR/DB.php");
$connect = "mysql://";
// Connect to the database
$db = DB::connect($connect);
if (DB::isError($db)) { die ("Can't connect: " . $db->getMessage()); }
// Set up automatic error handling
$db->setErrorHandling(PEAR_ERROR_DIE);
// Set up fetch mode: rows as objects
$db->setFetchMode(DB_FETCHMODE_ASSOC);
$filename="IDXActCm.txt";
$handle = fopen("$filename", "r");
while (($data = fgetcsv($handle, 100000, "|")) !== FALSE) {
$import="INSERT INTO commercial(Transaction_Type, MLSNumber, ListOfficeId, Address1, Address2, City, Company) VALUES('$data[0]', '$data[1]', '$data[2]', '$data[3]', '$data[4]', '$data[5]', '$data[6]')";
mysql_query($import) or die(mysql_error());
}
fclose($handle);