This is the command line SQL statement I wind up generating:
SQL:
mysql -h localhost --port=3306 -u me --password=ifyouonlyknew -D folks -e "LOAD DATA LOCAL INFILE '/home/me/docs/cma/data.csv' INTO TABLE contacts FIELDS TERMINATED BY ',' ESCAPED BY '\' OPTIONALLY ENCLOSED BY '""' LINES TERMINATED BY '\n' (title, first_name, last_name, position, school_company_org, department, address1, address2, address3, city, state, country, zip, main_phone, alt_phone, mobile_phone, fax, pager, main_email, alt_email, url )"
This is done via PHP script:
$sql = "mysql -h $hostname --port=$port -u $username --password=$password -D $dbDefaultName -e \"" .
"LOAD DATA LOCAL INFILE '$datafile' INTO TABLE contacts " .
" FIELDS TERMINATED BY ',' ESCAPED BY '\\\\' OPTIONALLY ENCLOSED BY '\"\"' " .
" LINES TERMINATED BY '\\n' " .
" (title, first_name, last_name, position, school_company_org, department, " .
" address1, address2, address3, city, state, country, zip, main_phone, " .
" alt_phone, mobile_phone, fax, pager, main_email, alt_email, url" .
" )\" ";
I am using the PHP script as CLI PHP to populate a MySQL database table with data from a CSV file in a command-line one-time shot. However, upon attempting to execute the value of $sql:
$msg = exec("$msg 2>&1");
if ($msg) echo $msg;
I get the wacky message:
And nothing is done. No table updates, nothing. I am using MySQL 4.0.10 and PHP 4.3.8 within Red Hat 7.3 environment.
Does anyone know what "PAGER set to stdout" means and why that appears, also, why my data cannot seem to be inserted into table? I have full permissions to do so.
Thanx
Phil