$connection = mysql_connect($db_host, $db_user, $db_password) or die("error with connection");
mysql_select_db($db_name, $connection);
$file=fopen("daily_user_summary.txt","r");
while (!feof($file_handle) ) {
$line_of_text = fgets($file);
$parts = explode(' ', $line_of_text);
print $parts[0]. $parts[1]. $parts[2] . $parts[3]. "<BR>";
$query = ("SELECT name, newcredit, sum(total), team FROM tb1 WHERE NAME = '$parts[0]' and TEAM = '$parts[3]'");
$row = mysql_fetch_row($query);
echo $row['name'] = $name;
echo $row['newcredit'] = $oldcredit;
echo $row['sum(total)'] = $oldwu;
echo $row['team'] = $team;
$updatequery = ("UPDATE tb1 SET newcredit='$parts[1]' AND sum(total)='$parts[2]' WHERE name = '$parts[0]' AND team = '$parts[3]'");
mysql_query($updatequery, $connection) or trigger_error("SQL", E_USER_ERROR);
}
fclose($file);
?>
</body>
</html>
I am trying to read a text file and insert values from the text file there are four values for each line that will be inserted into the database, there are 10000 of lines of information I need to insert and be able to update with new values. The code above works for reading the text file but when I try to use the updatequery the code craps out. I also am not sure if this code will work if there is a new user added to the text file if it will create its new information in the database on a new table insert.