[UNSOLVED] fopen() YARGH!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Post by $var »

i didn't fix it.. it's still not liking the first attempt... hmmm.
and the error thing you send didn't turn anything up either.


that's so fishy.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

what echos? The only ones I see are error returns.

I guess it's time to debug it like mad: comment out the header call, add echos giving out line numbers (__LINE__) in each if, beginning and ending of a loop, etc..
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Try This

Code: Select all

<?
$file = "surveys.txt";
$select = "SELECT * FROM `surveys` WHERE `Mem_ID` = ".$ID;
$export = mysql_query($select) or die(mysql_error()); 
while($row = mysql_fetch_assoc($export)){
	print_r($row);
	$fields = count($row);
	for ($i = 0; $i < $fields; $i++){ 
    	$header .= mysql_field_name($row[$i])."\t"; 
		$line = '';
        foreach($row as $value){                                             
			if (empty($value)){ 
				$value = "\t"; 
			} else { 
				$value = str_replace('"', '""', $value); 
				$value = '"' . $value . '"' . "\t"; 
			}
			echo $value;
			$line .= $value; 
		} 
		$data .= trim($line)."\n";
		echo $data;
	} 
} 

$data = str_replace("\r","",$data);  
             
if (empty($data)){ 
	$data = "\n(0) Records Found!\n";                         
} ELSE {
	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);
}
?>
Rewrote it in functions that I understand and added some debug info :)
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply