Well, my friends I have an almost working script on replacing values in a database from a text file.
<?php
// Make a MySQL Connection
mysql_connect("connection", "username", "pword") or die(mysql_error());
mysql_select_db("dbname") or die(mysql_error());
$nextline = '';
$fp = fopen('test.txt','r');
while (!feof($fp)) {
$mystuff = array();
$nextline = fgets($fp);
$mystuff = split(',',$nextline);
$casenumber = mysql_real_escape_string(trim($mystuff[0]));
$casename = mysql_real_escape_string(trim($mystuff[1]));
mysql_query("REPLACE INTO case_numbers
(casenumber, casename) VALUES('$casenumber', '$casename' ) ")
or die(mysql_error());
}
echo '<p>done!';
?>
The text file will be updated with new case numbers and names. When I added a new entry to the bottom of the text file and ran the above script, the new entry was added to the database. However, if I delete the last entry, the above script does not delete the entry from the database. There are only two fields in the table, casenumber and casename with casenumber set to unique. I'm sure it's just a little tweak to the query to see if one is missing and if so delete it. Any help would be much appreciated. It's taken me three days to get this far. Learned a lot doing this script...ha ha
Thanks in advance.
Twitch