User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,572 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,618 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 652 | Replies: 4 | Solved
Reply
Join Date: Oct 2007
Posts: 37
Reputation: drsmith is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
drsmith drsmith is offline Offline
Light Poster

PHP saving to a file

  #1  
Oct 26th, 2007
Having a strange problem with some PHP code.

This code:
$filename = "/u2/text/TOPAShiftlog".$dateString."_AShift.rtf";
writes the file TOPAShiftlog2007-10-26_AShift.rtf to the /u2/text dir.

I want it to write 2007-10-26_AShift.rtf to the /u2/text/TOPAShiftlog dir

so I tried this:

$filename = "/u2/text/TOPAShiftlog/".$dateString."_AShift.rtf";


This code ends up removing my "submit" button altogether. I don't understand why the / is causing the problem. Here is the meat of the code:

$filename = "/u2/text/TOPAShiftlog/".$dateString."_AShift.rtf";
     $handle = fopen("$filename","w");
	 $date1[$i]=$row['date'];

$message = "Station Log ";
$message = $message."Date: ".$date1[$i]." \n"	;
.....
$message = $message."\n\n";


	if(!fwrite($handle, $message)){
		print "Cannot write to file";
		exit; 		}
 	#print "Success, wrote ($message) to file ";
  $message = "";

	fclose($handle);    
    
     $i++;
    }
    ?>
        
  </table>
  <br><input type = 'hidden' name = 'todaym' value = <?=$todaym?>><input type = 'hidden' name = 'todayd' value = <?=$todayd?>><input type = 'hidden' name = 'todayy' value = '<?=$todayy?>'>
  <input type='submit' name='Submit' value='Submit'>

</form>

Any ideas would be appreciated
DS
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2007
Location: Chenoa, IL
Posts: 13
Reputation: bigattichouse is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
bigattichouse's Avatar
bigattichouse bigattichouse is offline Offline
Newbie Poster

Re: PHP saving to a file

  #2  
Oct 26th, 2007
When you do a view-source on the page, what is the output?
Need a simple, powerful knowledgebase? Bigattichouse Knowledge Base finds the solution while you're still typing the problem.
http://www.bigattichouse.com/knowledgebase.html
Reply With Quote  
Join Date: Oct 2007
Posts: 37
Reputation: drsmith is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
drsmith drsmith is offline Offline
Light Poster

Re: PHP saving to a file

  #3  
Oct 26th, 2007
The HTML code gets cut off before the end...doesn't even get to the "submit" portion of the code.
Reply With Quote  
Join Date: Oct 2007
Posts: 37
Reputation: drsmith is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
drsmith drsmith is offline Offline
Light Poster

Re: PHP saving to a file

  #4  
Oct 26th, 2007
Actually seems hit or miss. I just refreshed and get a "cannot write to file error" from the php script before the submit button code. So looks like it is erroring out before getting to Submit.
Reply With Quote  
Join Date: Oct 2007
Posts: 37
Reputation: drsmith is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
drsmith drsmith is offline Offline
Light Poster

Re: PHP saving to a file

  #5  
Oct 26th, 2007
It was a permissions problems. Looking at the view source pointed that out. Thanks.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 6:04 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC