Here is the code I use to parse browsenodes.com files into my db:
Code:
$quotelist = file("$url");
$db = mysql_connect("localhost", "user", "pw");
if (!$db) { echo( "<P>Unable to connect to the " . "database server at this time.</P>" ); exit();}
mysql_select_db("dbname", $db);
function addquote($element){
$quote_array = explode("|",$element);
$name = $quote_array[0];
$parentid = $quote_array[1];
$amazonid = $quote_array[2];
$mode = $quote_array[3];
global $db;
$result1 = mysql_query("INSERT blank_categories SET name = '$name', parentid = '$parentid', amazonid = '$amazonid', mode = '$mode'", $db);
if (!$result1) { echo("<P>Error performing query: " . mysql_error() . "</P>");
}
}
array_walk($quotelist, 'addquote');
?>
Its modified from a script I made to do much the same thing with quotes for my literature site's quote db so that explains the naming conventions. Access it like http://www.example.com/script.php?ur...enodesfile.txt
When getting the browsenodes.com files use | as a seperator and make sure it includes mode.
Bookmarks