To be able to write to a .data file i have to change the permissions within the unix server that I am using! Is there anyway I can do this through my code?
Here is my code:
<html>
<head>
<title>Write to file</title>
<link rel=stylesheet href=stylesheet.css>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
</head>
<?php
// 1. Select everything from the table sale
// 2. Enter into a while loop
// 3. Read all values into variables
// 4. Open a text file for writing
// 5. Write information on sale to text file
// 6. Exit while loop
// 7. Close file for writing
$db = mysql_connect("localhost", "d99kg", "password");
mysql_select_db("d99kg",$db);
$dbQuery="SELECT * FROM sale4";
$result = mysql_query($dbQuery,$db);
$out=fopen("fileCreateYourself.data","a") or die ("file won't open");
fwrite($out,"username,productid,name,date-bought,numbought,class\r\n");
while ($macInfo=mysql_fetch_array($result))
{
$productID=$macInfo["productID"];
$name=$macInfo["name"];
$dateBought=$macInfo["dateBought"];
$numBought=$macInfo["numBought"];
fwrite($out,"$productID,$name,$dateBought,$numBought\n");
}
fclose($out);
?>
<body>
<p><center><font size=5 style=bold></font></center> </p>
<table class=border align=center width=400 cellspacing=0 cellpadding=5>
<tr><th>Processing</th></tr>
<tr><td>
<form action=databaseControl.php>
<table width=100% cellpadding=3 cellspacing=5 border=0>
<tr><td align=center>
<font face=tahoma size=3 color=darkred>You have are now written recent customer transactions to
a file
</font>
</td></tr>
<tr><td align=center>
<font face=tahoma size=3 color=darkred>Thank you
</font>
</td></tr>
</table>
</form>
</td></tr>
</table>
<br>
<br>
<div align=center>
<input type=button value='Back to Main Menu'
onClick="document.location.href='databaseControl.php'">
</div>
</body>
</html>
Thanks for your help!