Forum Moderators: coopster

Message Too Old, No Replies

More fun with CSV

Now I need to save the output

         

TonyL

5:44 pm on Jan 19, 2004 (gmt 0)

10+ Year Member



Hi again.

Having had help to figure out pulling data from a CSV into a HTML form now I need to take the info and save it to another CSV file. I have written some code for it. As far as I can tell it opens the file and I know that it is getting the $_Post variables but it will not add the data to the CSV?

TonyL

5:45 pm on Jan 19, 2004 (gmt 0)

10+ Year Member



oh yeah the code I have is:

<?

if(!$fp = fopen("calls.csv", "r")){

die ("Cannot open data file");

} else {

print 'Connected to CSV';

}

$writetocsv= $_POST['NBSCRef'] . "," . $_POST['NBSCName'] . "," . $_POST['CallTaker'] . ","

. $_POST['ManualRef'] . "," . $_POST['DateLogged'] . "," . $_POST['TimeLogged'] . "," .

$_POST['FAD'] . "," . $_POST['SiteName'] . "," . $_POST['CallerName'] . "," .

$_POST['Position'] . "," . $_POST['Address'] . "," . $_POST['City'] . "," . $_POST['State']

. "," . $_POST['Zip'] . "," . $_POST['PhoneNumber'] . "," . $_POST['CallType'] . "," .

$_POST['ProblemType'] . "," . $_POST['Severity'] . "," . $_POST['Priority'] . "," .

$_POST['NoofCounters'] . "," . $_POST['NodeAffected'] . "," . $_POST['ProblemDescription'] .

"," . $_POST['Action1'] . "," . $_POST['Action2'] . "," . $_POST['Action3'] . "," .

$_POST['Action4'] . "," . $_POST['Action5'] . "," . $_POST['Action6'] . "," .

$_POST['Action7'] . "," . $_POST['Action8'] . "," . $_POST['Action9'] . "," .

$_POST['Action10'] . "," . $_POST['AccessTimes'] . "," . $_POST['NodeStatus'] . "," .

$_POST['Recommend'] . "," . $_POST['Spares1'] . "," . $_POST['Spares2'] . "," .

$_POST['Spares3'] . "," . $_POST['Spares4'] . "," . $_POST['Spares5'];

fwrite($fp,$writetocsv);

fclose($fp);

?>

BitBanger

6:03 pm on Jan 19, 2004 (gmt 0)

10+ Year Member



Shouldn't the file mode be write?
if(!$fp = fopen("calls.csv", "w")){

TonyL

9:13 am on Jan 20, 2004 (gmt 0)

10+ Year Member



This si what I thought but it just returns and error:

Warning: fopen("calls.csv", "w") - Permission denied in

"r" is the only one that actually opens the file successfully

BitBanger

2:07 pm on Jan 20, 2004 (gmt 0)

10+ Year Member




Warning: fopen("calls.csv", "w") - Permission denied in

Then it is probably the permissions on the file and/or directory on the server. These can usually be changed by your FTP client.