Page 1 of 1

How is datat stored and retrieved on the server side?

Posted: Tue Aug 25, 2009 9:36 pm
by kutchbhi
I know about mysql . data can be stored in tables and received through queries.
But there has to be other ways/techniques server side information is stored . JavaScript tricks or something.
Just give me lil hint if you don't want to give a detailed answer.

btw I am talking about saving server side , not cookies or temporary variables.

Reason : making a website that takes user input , stores and displays later in different php pages.. So I want the input to be stored in some variable and then displayed
The only way I can think of is using database , but thats something I want to avoid. Its a small website and I am terrible programmer.

Also another answer I got for this question was that its all database only . SO is all the information(email,google's index) stored on the internets is in databases ?

ta

Lastly how is this site doing it ? its just 2 variables...

Re: How is datat stored and retrieved on the server side?

Posted: Wed Aug 26, 2009 8:36 am
by Stoker
you can store in flatfiles - but not recommended unless it is a true write-once-read-many need,,
otherwise you would have to deal with locking and simultaneous writes, partial reads etc..

check the php manual for reading and writing files (fopen, fwrite)

Re: How is datat stored and retrieved on the server side?

Posted: Wed Aug 26, 2009 11:56 am
by Benjamin

Code: Select all

 
session_start();
$_SESSION['foo'] = 'bar';
 
:arrow: Moved to PHP - Code

Re: How is datat stored and retrieved on the server side?

Posted: Thu Aug 27, 2009 9:37 am
by kutchbhi
you can store in flatfiles
Thanks for the tip . I found this link: http://www.xentrik.net/php/flatfile.php . Which is absolutely perfect for my needs! :)
But I do not understand the problem the write-once-read many problem. Could you elaborate on that ? Here is the write-into-file code
<?php
$name = "string";

$fp = fopen("data.txt","a");
fwrite($fp, $name\n");

fclose($fp);
?>
What exactly is the problem here please ?
would it be a problem if data.txt is written into say 50 times a day ?

Re: How is datat stored and retrieved on the server side?

Posted: Thu Aug 27, 2009 9:43 am
by jackpf
I think what Stoker means is that if you write to the file a lot, there is the chance that the file could be written to twice at the same time...which would screw it up.

In order to write to it properly, you'd have to lock the file so no one else can access it while it's being written to...but then obviously other users will have to wait.

Also, flat files are harder to modify, and retrieve the particular parts you want. As well as this, databases can be a lot quicker with indexes, since you only select the data you require.

Why don't you want to use a database?

Re: How is datat stored and retrieved on the server side?

Posted: Thu Aug 27, 2009 11:58 am
by kutchbhi
Why don't you want to use a database?
1. small small website that may never take off. And I guess the flatfile would be open only for a few milliseconds for every write. I can take that chance
2. I am terrible programmer
3. free account on 110mb don't let any database

besides this solution fits my needs perfectly

Re: How is datat stored and retrieved on the server side?

Posted: Thu Aug 27, 2009 12:56 pm
by jackpf
There are plenty of free hosts that offer databases.

It will be better in the long run imo...but it's your choice.