do i need msql to make a comments page on my website. i have a cgi bin.You can use a text file but generally a database is used to store information. Text files are a bit slower for searching, db servers have been optimized for that task.how would i load the text file?That depends on the language your using....dont know. php?Then I am not the person to be answering the questions .... you might want to go to the sub forum PHP...
Also your uncertainity is odd, how do you not know what language you will be using to do this.....lol ive never done it before......im not certain its a learning experience.Originally posted by Thamior
dont know. php?
Somebody here in PHPLand should be able to help you.
If not, then I'm gonna have to start thwomping some heads lol ok.what are you trying to do?
do you just want a list of comments made by people - that's not too difficult...
PHP can read and write to local files, so long as you know the path to them.
$file = fopen($filename, "a");
will let you start writing from the end of the file, so you can add to it..
$file = fopen($filename, "a+");
lets you read and write - but you have to reposition the cursor..
$file = fopen($filename, "r");
lets you read from the beginning..
fwrite($file, $string);
writes in a string - remember to terminate the line with the correct end of line sequence.
$file = fopen($filename, "r");
while (!eof($file))
{
$lines[] = fread($file);
}
fclose($file);
you must always remember to close the file...ok, so this allows me to read and store things in a file? how to a move the cursor to a certain character. for instance the 1rst character will probally be a number representing the number of messages. then i'll end line then I'll start to read the messages. but if i put the messages in individual tables i need to know where one message ends and another begins.ok i was testing file reading and it isnt working.
<!-- m --><a class="postlink" href="http://sahel.micfo.com/~gaiachar/test.htmlcould">http://sahel.micfo.com/~gaiachar/test.htmlcould</a><!-- m --> we have a look at your PHP script?
make things easier ok here you are...i don't understand this bit:
echo "File stuff ".$lines[filesize($filename)];
actually, i told you slightly the wrong function...
use this to read the text file:
while (!feof($file))
{
$lines[] = fgets($file);
}
this just reads one line at a time from the text file into the array.
and just use
echo $lines[0];
to display the first entry...Thank you . Now i just need to write to the file and figure out how to use end of line characters since \n doesnt work. would writing to the file be fputs?i haven't actually used PHP to write to a file...
but fputs should be fine...
MS end of line sequence are \r\n
i think Mac's are \n
and Linux/Unix are \r (or the other way round)...Warning: fopen(comments2.txt): failed to open stream: Permission denied in /home/gaiachar/public_html/test.php on line 22 I ve got this as a warning. *sigh*You will need to chmod the file using a shell account
chmod 777
if i remember that correctly from 5 years ago...
Also your uncertainity is odd, how do you not know what language you will be using to do this.....lol ive never done it before......im not certain its a learning experience.Originally posted by Thamior
dont know. php?
Somebody here in PHPLand should be able to help you.
If not, then I'm gonna have to start thwomping some heads lol ok.what are you trying to do?
do you just want a list of comments made by people - that's not too difficult...
PHP can read and write to local files, so long as you know the path to them.
$file = fopen($filename, "a");
will let you start writing from the end of the file, so you can add to it..
$file = fopen($filename, "a+");
lets you read and write - but you have to reposition the cursor..
$file = fopen($filename, "r");
lets you read from the beginning..
fwrite($file, $string);
writes in a string - remember to terminate the line with the correct end of line sequence.
$file = fopen($filename, "r");
while (!eof($file))
{
$lines[] = fread($file);
}
fclose($file);
you must always remember to close the file...ok, so this allows me to read and store things in a file? how to a move the cursor to a certain character. for instance the 1rst character will probally be a number representing the number of messages. then i'll end line then I'll start to read the messages. but if i put the messages in individual tables i need to know where one message ends and another begins.ok i was testing file reading and it isnt working.
<!-- m --><a class="postlink" href="http://sahel.micfo.com/~gaiachar/test.htmlcould">http://sahel.micfo.com/~gaiachar/test.htmlcould</a><!-- m --> we have a look at your PHP script?
make things easier ok here you are...i don't understand this bit:
echo "File stuff ".$lines[filesize($filename)];
actually, i told you slightly the wrong function...
use this to read the text file:
while (!feof($file))
{
$lines[] = fgets($file);
}
this just reads one line at a time from the text file into the array.
and just use
echo $lines[0];
to display the first entry...Thank you . Now i just need to write to the file and figure out how to use end of line characters since \n doesnt work. would writing to the file be fputs?i haven't actually used PHP to write to a file...
but fputs should be fine...
MS end of line sequence are \r\n
i think Mac's are \n
and Linux/Unix are \r (or the other way round)...Warning: fopen(comments2.txt): failed to open stream: Permission denied in /home/gaiachar/public_html/test.php on line 22 I ve got this as a warning. *sigh*You will need to chmod the file using a shell account
chmod 777
if i remember that correctly from 5 years ago...