[UNSOLVED] fopen() YARGH!
Posted: Tue Feb 21, 2006 10:22 am
A few months back I asked about this code, and eventually got it to work... and while i moved on in projects, someone pointed out that it has ceased working...
I don't feel that I have made any changes to the page, or the database but it now exports the error (0) Records Found!
I echoed out the select, and it is pulling the right ID still, so i am not quite sure where the problem is... the actual data is in the database.
I don't feel that I have made any changes to the page, or the database but it now exports the error (0) Records Found!
I echoed out the select, and it is pulling the right ID still, so i am not quite sure where the problem is... the actual data is in the database.
Code: Select all
<? $select = "SELECT * FROM surveys WHERE Mem_ID =".$ID;
$file = "surveys.txt";
$export = mysql_query($select);
$fields = mysql_num_fields($export);
for ($i = 0; $i < $fields; $i++) {
$header .= mysql_field_name($export, $i) . "\t";
while($row = mysql_fetch_row($export)) {
$line = '';
foreach($row as $value) {
if ((!isset($value)) OR ($value == "")) {
$value = "\t";
} else {
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
}
}
$data = str_replace("\r","",$data);
if ($data == "") {
$data = "\n(0) Records Found!\n";
}
if (!$file_handle = fopen($file,"a")) { echo "Cannot open file"; }
if (!fwrite($file_handle, $data)) { echo "Cannot write to file"; }
header("Location: http://www.advantageboard.com/access/02 ... elcome.php");
fclose($file_handle);
?>