Jump to content

Load data infile help


dennismonsewicz

Recommended Posts

I am trying to use the mysql command LOAD DATA INFILE and then spit out the results from the DB and I get nothing.

 

No errors or anything.

 

<?php
mysql_connect('localhost', 'username', 'password')or die(mysql_error());
mysql_select_db('db_name')or die(mysql_error());

$insert = mysql_query("LOAD DATA LOCAL INFILE 'myfile.csv'
					INTO TABLE mytbl FIELDS TERMINATED BY ','
					LINES TERMINATED BY '\n'
					(`make`, `model`, `deductible`, `published`)")
		or die(mysql_error());

if($insert) {
	$query = mysql_query("SELECT * FROM mytbl");
	while($row = mysql_fetch_object($query)) {
		$results .= $row;
	}
	echo '<pre>';
	print_r($results);
	echo '</pre>';
} else {
	echo 'NOPE!';
}
?>

Link to comment
https://forums.phpfreaks.com/topic/194814-load-data-infile-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.