PDA

Click to See Complete Forum and Search --> : Reading Text File and Updating Database


lintz
Oct 20th, 2004, 09:52 PM
I'm using the code below to read a txt file from my site then looping through it 1 line at a time and updating user details. The problem is if the txt file has more than 1 line the database is not updated. Can anyone help me out?

include("db_connect.php");

$array_tmp = file('osprey.txt');

foreach($array_tmp as $v) {
$Update_Details = mysql_query("UPDATE tblUsers SET OSPREY = 'YES' WHERE username = '$v'");
}

echo "All Complete"

visualAd
Oct 21st, 2004, 04:14 AM
The file function takes newline characters with it too. Use the trim function on $v.