Jump to content

Archived

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

obyno

problem with inserting from text file arrays

Recommended Posts

trying to insert from three text files of 1000 tab delimited lines into db lets me go only as far as 255 rows and no further each time.And then of these a select query comes up blank via an html form page.Please what could be the prob.Anyone help?

 

 

I need to have the insertions done like - have the first element of the phonenumber.txt file inserted under phonenumber column, then have the first element of the name.txt file go into the name column of db, then the address column go in after it;then have this repeated row row for the three files until all the data has been inserted.When I do it all in one insert statement nested in foreach statements i receivemultiples of each elment for...really hope you can help.Thanks for caring

 

 

 

<?

include \"db.php\";

 

$nu = @fopen(\"phonenumber.txt\", \"r\")

or die(\"<br>Failed to open file: <i>phonenumber.txt</i>.\");

$array = file(\"phonenumber.txt\");

 

 

$nu = @fopen(\"userlist.txt\", \"r\")

or die(\"<br>Failed to open file: <i>userlist.txt</i>.\");

$array1 = file(\"userlist.txt\");

 

 

$nu = @fopen(\"password.txt\", \"r\")

or die(\"<br>Failed to open file: <i>password.txt</i>.\");

$array2 = file(\"password.txt\");

 

 

for ($i=0; $i<count($array); $i++)

{

$myquery = \"INSERT into totalled (phoneNumber, user, password) VALUEs (\'$array[$i]\', \'$array1[$i]\', \'$array2[$i]\')\";

$result = mysql_query($myquery, $ok);

if (!$result)

{

echo \"Nothing\";

}

}

 

?>

Share this post


Link to post
Share on other sites

×

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.