Code:
<?php
mysql_connect("localhost","user_name") or die("could not connect");
mysql_select_db("my_database_name") or die("could not select database");
$file = "file_that_contains_names_one_name_in_a_line";
if (!$file_handle = fopen($file,"r")) { echo "Cannot open file."; }
if (!$file_contents = fread($file_handle, filesize($file))) { echo "Cannot read contents of file"; }
$array=preg_split('/\n/',$file_contents);
while(list($name,$value)=each($array))
{
if($value!="")
{
$name_add_query="insert into name_table values('$value')";
mysql_query($name_add_query);
}
}
fclose($file_handle);
?>
I suppose that should do it. I don't have a linux machine right now available and so didn't check it .
But I think it works fine