How is datat stored and retrieved on the server side?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kutchbhi
Forum Newbie
Posts: 12
Joined: Mon Aug 24, 2009 2:00 pm

How is datat stored and retrieved on the server side?

Post 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...
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

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

Post 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)
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

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

Post by Benjamin »

Code: Select all

 
session_start();
$_SESSION['foo'] = 'bar';
 
:arrow: Moved to PHP - Code
kutchbhi
Forum Newbie
Posts: 12
Joined: Mon Aug 24, 2009 2:00 pm

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

Post 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 ?
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

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

Post 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?
kutchbhi
Forum Newbie
Posts: 12
Joined: Mon Aug 24, 2009 2:00 pm

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

Post 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
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

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

Post 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.
Post Reply