Hi, I apologize for all the emails on this, but I'm truly at a loss here and really need some input as to what I need to do to get this working.
I have a FORM with two drop down menus and have the entries saved in two separate .inc files i.e: <Option Value="3">Alfredsson <Option Value="39">Arnott <Option Value="150">Aucoin <Option Value="143">Audette Etc... <Option Value="67">Bates <Option Value="36">Battaglia <Option Value="152">Berard <Option Value="6">Bertuzzi Etc.... The user enters the webpage and chooses a player from list one and list two. This gets submitted to my PHP script which reads in these files and manipulates them accordingly and re-saves them. At the end of the PHP script I include the input file again - include("injury-input.php") - which should now have the updated drop down menus. This seems to work the first time you open up a browser and go to the input page (although I can't really even be sure of that now). If you try to do it again using a different set of players, it doesn't work. I usually end up with two empty files. So it appears it is opening the file the second time ok, but is not writing to it. I have no idea what to do with this. Here is the script: function writeplayer($from_row, $to_row) { include("trade-errors.inc"); $filename = "players.inc"; $fd = fopen ($filename, "r"); $content = ""; while (!feof ($fd)) { $content = fgets($fd); if (preg_match ("/".$to_row['player']."/", $content)) { } else { $list[] = $content; } } fclose ($fd); $num = count($list); $list[$num] = "\r\n<Option Value=\"".$from_row['idp']."\">".$from_row['player']; $num = count($list); $list = preg_replace('/(<.*?>)(.*)/', '$2$1', $list); sort ($list); $list = preg_replace('/(.*?)(<.*>)/', '$2$1', $list); if (is_writable($filename)) { if (!$fp = fopen($filename, 'w')) { $injury_errors = $playeropens; include("injury-input.php"); exit; } for($i=0; $i < $num; $i++) { if (!fwrite($fp, $list[$i])) { $injury_errors = $playerwrite; include("injury-input.php"); exit; } } fclose($fp); } else { $injury_errors = $notwritable; include("injury-input.php"); exit; } unset($list); unset($content); unset($num); unset($filename); unset($fd); unset($fp); writereserve($from_row, $to_row); $injury_errors = $updated; return($injury_errors); } function writereserve($from_row, $to_row) { include("trade-errors.inc"); $filename = "players-reserve.inc"; $fd = fopen ($filename, "r"); $content = ""; while (!feof ($fd)) { $content = fgets($fd); if (preg_match ("/".$from_row['player']."/", $content)) { } else { $list[] = $content; } } fclose ($fd); $num = count($list); if (is_writable($filename)) { if (!$fp = fopen($filename, 'w')) { $injury_errors = $playeropens; include("injury-input.php"); exit; } for($i=0; $i < $num; $i++) { if (!fwrite($fp, $list[$i])) { $injury_errors = $playerwrite; include("injury-input.php"); exit; } } fclose($fp); } else { $injury_errors = $notwritable; include("injury-input.php"); exit; } $injury_errors = $updated; unset($list); unset($content); unset($num); unset($filename); unset($fd); unset($fp); return($injury_errors); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php