|
-
Nov 3rd, 2001, 12:27 PM
#1
PHP Programming, or Perl or whatever
Hi. I have no idea how to program in PHP or Perl, but I hope you can help. Is there a way to save a file on a server (like a text file) using PHP or Perl and then retrive that data from the server (for example like creating a poll - you save the number of answers for each question and then retrive the data to show the results). Any help would be greatly appreciated.
Also, if you know the answer to above question, the second part would be: how do you read the file from the server line by line (if it's even possible) and store that data in an array?
Thanks
Spike
-
Nov 3rd, 2001, 06:40 PM
#2
PowerPoster
Why don't you learn a little about PHP or Perl first. We could help you better that way.
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Nov 4th, 2001, 12:34 AM
#3
First of all I know that much 
Second I don't have really have time to do much research on PHP or Perl at this moment. School is killing me, my boss just wants the job done (using PHP or Perl - bastard) and I already sleep 3 hours a night
Thanks anyway
Spike
-
Nov 4th, 2001, 02:42 PM
#4
your best bet would to be to save the data in a database, being a flat file or Mysql
-
Nov 5th, 2001, 02:00 AM
#5
Conquistador
mySQL is easy but probably too powerful for a poll...
-
Nov 5th, 2001, 05:23 AM
#6
Hyperactive Member
Perl example:
Code:
$file = "poll.txt";
$input = "this is my result";
#create a file and add to it, INPUTPOLL is the file handler this can be any name you like
open (INPUTPOLL, "> $file) or die "can't open file for input";
print INPUTPOLL $input;
close INPUTPOLL;
#open the file and read the contents
open (OUTPUTPOLL, "< $file") or die "can't open file for output";
$poll_results = <OUTPUTPOLL>;
close OUTPUTPOLL;
#display in browser
print"Content-Type: text/html\n\n";
print $poll_results;
some things you should know about opening files:
if you notice in the open line there is a > or a <
> means create or overwrite
>> (not used above) means create, and append
< means open file for readiing
You can not open a file for writing and reading at the same time!!
This should get u started!
-
Nov 5th, 2001, 08:03 AM
#7
Conquistador
PHP Code:
$fp = @fopen("poll.txt", "r");
fpassthru ($fp);
@fclose ($fp);
Opening and displaying file poll.txt in PHP
You can open for write and read access at the same time!
-
Nov 5th, 2001, 09:43 AM
#8
Originally posted by da_silvy
mySQL is easy but probably too powerful for a poll...
oh I don't know about that, it's what I use
-
Nov 5th, 2001, 10:21 AM
#9
Conquistador
for a noob
i think he should learn text files, then databases.
-
Nov 5th, 2001, 10:54 AM
#10
Hyperactive Member
for a noob
I think he should learn text files, then databases.
I second that, although something as simple as a poll would be a good stepping stone to a DB from a flat file system ( for a learning project in the future ).
Both have there advantages working with flat files you tend to pick up a lot of pattern matching skills, and working with databases, well, you pick up SQL skills!
IMHO: for such a simple project as a poll it's more time efficient to write a script for a flat file than a DB!
-
Nov 5th, 2001, 11:53 AM
#11
Black Cat
In Perl, you could use a DBM file (or emulation) to bind a hash to a file.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Nov 5th, 2001, 02:53 PM
#12
Stuck in the 80s
Perl doesn't really take that long. I would suggest finding some tutorials. Reading and writing files are one of the first things that are probably covered.
-
Nov 5th, 2001, 03:07 PM
#13
Originally posted by progressive
I second that, although something as simple as a poll would be a good stepping stone to a DB from a flat file system ( for a learning project in the future ).
Both have there advantages working with flat files you tend to pick up a lot of pattern matching skills, and working with databases, well, you pick up SQL skills!
IMHO: for such a simple project as a poll it's more time efficient to write a script for a flat file than a DB!
I would have to agree too, but I passed the flat file up and went to mysql when I learned. I think the flat file is hard to learn for me that is. but everybody has their choice.
-
Nov 6th, 2001, 12:09 AM
#14
Conquistador
Yeah...
I think database is more convenient.
IMHO: PHP is better than perl too 
I just like it more...
I haven't put much effort into learning perl, but PHP is pretty easy to pick up
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|