Jump to content

[SOLVED] Error with code, but won't display what...


Sesquipedalian

Recommended Posts

For some reason it won't display what the error is with my code..

This is just an exert of some code, but I know that there is an error somewhere in here that is messing up my other code, I just can't find it.

 

What do you think?:

 

<?
        $assignments = 'assignments.txt';
$archive = 'archive.txt';
chmod($archive, '0777');
chmod($assignments, '0777');
if ($handle['assignments'] = fopen($assignments, 'r')) {
	if ($read = fread($handle['assignments'], filesize($assignments))) {
		if ($handle['archive'] = fopen($archive, 'a')) {
			$string = $_POST['subject'].'|'.$_POST['assignment'].'|'.$_POST['date'];
			$read = explode("\n", $read);
			for ($i=0;$read[$i]!==NULL;$i++) {
				if ($read[$i] !== $string) {
					$newread .= $read[$i];
					if ($read[$i+1]!==NULL) {
						$newread .= "\n";
					}
				} else {
					$archivedstring = $read[$i];
				}
			}
			fclose($handle['assignments']);
			if (fwrite(fopen($assignments, 'w'), $newread)) {
				if (fwrite($handle['archive'], $archivedstring)) {
					echo '<script>self.close();</script>';
				} else {
					echo 'Cannot write to archive.txt';
				}
			} else {
				echo 'Cannot write to assignments.txt';
			}
		} else {
			echo 'Cannot open '.$archive.' for writing.';
		}
	} else {
		echo 'Cannot read '.$assignments;
	}
} else {
	echo 'Cannot open '.$assignments.' for reading';
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.