Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
How to log to unique files?
Old 09-27-2003, 07:49 PM How to log to unique files?
Average Talker

Posts: 21
Trades: 0
Hi, I've created a form on a Web page which allows a user to make comments and state any problems/issues.
At the moment, the forms logs the user issues to one long text file. I'd like it to log the issues to separate text files.

Any ideas how I can log each problem to separate text files and ensure that I don't overwrite any of the existing text files?

Here is the code so far, which logs to only 1 file so far. By the way, my Web space uses only PHP3.

ProcessForm.PHP:
-------------------
<?php

$myFileHandle = fopen('problem1.txt','a') or die("can't open file");

if (-1 == fwrite($myFileHandle,date("D j M Y g:i a").chr(10))) { die("can't write data"); }
if (-1 == fwrite($myFileHandle,$txtCompany.chr(10))) { die("can't write data"); }
if (-1 == fwrite($myFileHandle,$txtAddress.chr(10))) { die("can't write data"); }
if (-1 == fwrite($myFileHandle,$txtPhoneNumber.chr(10))) { die("can't write data"); }
if (-1 == fwrite($myFileHandle,$txtEmail.chr(10))) { die("can't write data"); }
if (-1 == fwrite($myFileHandle,$txtComments.chr(10))) { die("can't write data"); }
if (-1 == fwrite($myFileHandle,$txtProblem.chr(10))) { die("can't write data"); }
if (-1 == fwrite($myFileHandle,$txtProblemFound.chr(10))) { die("can't write data"); }
if (-1 == fwrite($myFileHandle,$txtReason.chr(10))) { die("can't write data"); }
if (-1 == fwrite($myFileHandle,$txtDateOfProblem.chr(10))) { die("can't write data"); }
if (-1 == fwrite($myFileHandle,$txtProblemCaused.chr(10))) { die("can't write data"); }
if (-1 == fwrite($myFileHandle,"-----".chr(10))) { die("can't write data"); }

fclose($myFileHandle) or die("can't close file");

?>
-------------------

Thanks for your suggestions,

May
may_hem1 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-28-2003, 11:11 AM
david's Avatar
King Spam Talker

Posts: 1,314
Location: Glasgow, UK
Trades: 0
How about storing the last incident number in a file called numbers.txt. Then each problem opening this file, reading the number, incrementing it, overwriting the existing file, then naming the problem file:
'problem'.$nextnum
which will give it the next number.

Or you could do it with dates. You could have a problems folder in your webspace and store files as:
yyyymmddhhmmss.txt
which would give you some more details on the error.
__________________

Please login or register to view this content. Registration is FREE
- Everything a webmaster needs - for free

Please login or register to view this content. Registration is FREE
- Free web hosts reviewed and rated

Please login or register to view this content. Registration is FREE
- Impartial hosting directory - Add your host today for FREE
david is offline
Reply With Quote
View Public Profile
 
Old 09-28-2003, 05:25 PM
Average Talker

Posts: 21
Trades: 0
Thanks David!

I'll go with the dates method. I used fopen("problem".date( ),"a")

May
may_hem1 is offline
Reply With Quote
View Public Profile
 
Old 10-15-2003, 07:35 PM
Skilled Talker

Posts: 67
Location: Erin, NY
Trades: 0
how about try using a mysql database and create a results page
ltcjohnson is offline
Reply With Quote
View Public Profile Visit ltcjohnson's homepage!
 
Reply     « Reply to How to log to unique files?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.61046 seconds with 12 queries