#!/usr/local/pkg/php-5.0.4/bin/php -q

<?php

// Establish connection parameters
//
	$hostname = "astraea2";   //declaring variables for mysql access
	$databasename = "gbo_asi_rt_mirror"; //all these values are 
																		   //unavailable to the user and thus secure
	$username = "thmsoc";   //these will have to be set for all search forms that 
												  //access the mysql database
	$password = "ishkabibel";

	if ($_SERVER['argc'] !=3) {
		die("Check arguments: Need table name and file with full path\n") ;
	}

// Assign command line input variables
//
	$table_name = $_SERVER['argv'][1] ;
	$file = $_SERVER['argv'][2] ;

	/*
	print "table_name = " . $table_name . "\n" ;
	print "file = " . $file . "\n" ;
	*/
	
// Make connection to MySQL server
//
$databaselink = mysql_connect($hostname, $username, $password) 
		or die("Could not connect: " . mysql_error());

// Select particular database
//
	mysql_select_db($databasename, $databaselink) or die("Could not use database: $databasename");

// Construct and insert new input
//
	$db_input = "load data local infile \"$file\" into table $table_name fields terminated by \",\" (DataTime,FileName,ProcessTime,ProcessCode,FileSize)";
	mysql_query($db_input)
		or die("Could not query: " . mysql_error());

?>
