MySQL Forums
Forum List  »  Newbie

Trouble Inserting entries to MySQL with PHP
Posted by: Sanggra Baginda
Date: August 11, 2004 10:49PM

I'm writing a script for inserting entries to a table on MySQL db with . Each entry is come from a text file which is separated with a function. And the text files are read from a directory recursively, so after we input a directory name, the script will find all the text files within that directory, separates them into fields, and inserts them to a table on db as soon as the file found and separated into fields.
THis is the global view of my functions
function retrieveDirs($path)
// the body of this function is get the absolute path for
// all text files within the directory specified by $path
// and call itself (recursive) as soon as it found the directory
// inside $path
// THis fuction calls insert_file_to_db($file) as soon as
// it gets the absolute path of a text file
// which insert
if (is_file($file))
if (is_dir($file))

function insert_file_to_db($file)
// THis function call get_contents($file)
// for separation of field
// the query for insert is here

function get_content($file)
//THis function separates reads text file, separates them to
// fields (match to the target table) and return an array of fields
// that is ready to insert to db

So there will be n consecutive sql queries for n files found to a table i meant.
THe script works find for a file, but The problem is not all of them (text files within directory) inserted. Ex if i have 10 text files in the directory input, only about 6 or 7 suceeds.
WHat i'm questioning is that the script that works in milisecond range, is that affecting the queries? i mean it looks like "the next file found, separated, and inserted before the current file had already done inserted." that cause that such of things.
I'm looking forward for replies and acks such for solving this problem so much.

Options: ReplyQuote

Written By
Trouble Inserting entries to MySQL with PHP
August 11, 2004 10:49PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.