|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
I have been trying to read the contents off three(3) text files comprising phonenumbers, names and addresses, and write them into a database table of three fields of similar names.Except I keep getting the unwanted results with these codes.Can somebody please look and help urgently?Thanks.Appreciate.
The code I used: <?php 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"); foreach ($array as $fd) { foreach ($array1 as $fg) { foreach ($array2 as $fx) { $myquery = "INSERT into totalled (phoneNumber, user, password) VALUEs ('$fd', '$fg', '$fx')"; $result = mysql_query($myquery, $ok); if (!$result) { echo "Nothing"; } } } } ?> Last edited by obi : March 19th, 2003 at 04:07 AM. |
|
#2
|
|||
|
|||
|
I don't know what your results are, but:
Why don't you try replacing $array = file("phonenumber.txt"); with $fd = file("phonenumber.txt"); Try doing your inserts one at a time. Try echo mysql_error(); after the query |
|
#3
|
|||
|
|||
|
ooops
Got it afterall courtesy of a friend.Thanks for helping out rickwright. Just so it doesnt fry another fellows brains like it did mine, what works should go like this: <? 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"; } } ?> |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > need help with this |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|