Code: Select all
<?php
$names = array( "Bill", "Kathleen", "Kris", "Susan", "Don", "Kimberly", "Matt", "Makena");
$codes = array( 5431, 6147, 6742, 9086, 5442, 7593, 3234, 6561);
?>Code: Select all
<?php
// Place all records from the file in a array and return it
function listall()
{
$name = "files/lst" . $_SESSIONї'viewing'] . ".dat"; // ie "lst6147.dat"
$r = "";
$f = @fopen($name, "r");
if ($f != FALSE)
{ $a = fread($f, filesize($name)); // read the whole file
fclose($f);
$r = trim($a);
}
return $r;
}
// Get a specific record from the file based on the record number
function getrec($id)
{
// Integer: $id = record number to retrieve
$d = explode("~", listall());
return $dї$id];
}
// Put a specific record into file based on id number
function putrec($id, $rec)
{
// Integer: $id = record number to replace
// String: $rec = string to replace in the file
$d = explode("~", listall());
$dї$id] = $rec;
$w = implode("~", $d);
$name = "files/lst" . $_SESSIONї'viewing'] . ".dat"; // ie "lst6147.dat"
$f = fopen($name, "w"); // for writing, truncated
fwrite($f, $w);
fclose($f);
}
// Put a specific record onto end of file
function addrec($rec)
{
// String: $rec = string to replace in the file
$name = "files/lst" . $_SESSIONї'viewing'] . ".dat"; // ie "lst6147.dat"
$s = @filesize($name);
$f = fopen($name, "a"); // for append at end of file
if ($s) fwrite($f, "~");
fwrite($f, $rec);
fclose($f);
}
?>Code: Select all
<?php
session_start();
include "codes.php";
include "functs.php";
$r = array($Name, $Desc, $Size, $Store, $Cost);
$rї5] = $_SESSIONї'ucode'];
$rї6] = $Vis;
$rї7] = "";
if (!strcmp($Flagged, "yes")) $rї7] = $_SESSIONї'ucode'];
$f = implode("|", $r);
addrec($f);
header("Location:select.php?Selection=" . $_SESSIONї'viewing']);
?>The file does not exist, but the fopen function should creadte it, right?
The "files" directory has permission for all levels (CHMOD 777).
Secondly, I'm getting a "cannot add headers, data already sent" error on the last line of addrec.php, but I simply cannot see where any data has been sent to the browser.
Help?