Jump to content

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';
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.