Php to store variables

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
GandolfMatt
Forum Newbie
Posts: 5
Joined: Fri Aug 08, 2008 1:45 pm

Php to store variables

Post by GandolfMatt »

Hey, I'm new to php, but I have to create a simple php page that will store a variable as text when a desktop app sends the data up to it.
Send data to be saved by it:

http://www.example.com/gmmmo/examplepage.php "-d m=" & variabletosend

and to retrieve it just by typing in the page:

http://www.example.com/gmmmo/examplepage.php


Anyone know how?


Thanks,
-Matt
nowaydown1
Forum Contributor
Posts: 169
Joined: Sun Apr 27, 2008 1:22 am

Re: Php to store variables

Post by nowaydown1 »

Hey Matt,

Welcome to the forum! You have a lot of options here depending on what your specific needs are. You need to think about things like:

* Do multiple clients need to store different values for the variable? If so, that will toss some complexity into the mix.
* How long do I need the data to persist for? If you only need it to stay resident for a short while (minutes, hours), sessions might be an option.
* What sort of performance / requests per second do I need to be able to handle? If you expect low traffic, you could use a file on the disk to store the variable. If you need a higher volume, I would use a database.

Generally, storage for most web applications happens with a database, primarily MySQL. Once you decide on which method would meet your needs, you can look at researching implementation details using the php.net site and Google. If you have any additional questions, feel free to ask!
GandolfMatt
Forum Newbie
Posts: 5
Joined: Fri Aug 08, 2008 1:45 pm

Re: Php to store variables

Post by GandolfMatt »

Thanks.
* Do multiple clients need to store different values for the variable? If so, that will toss some complexity into the mix.
Multiple clients do, but they first read the value and rewrite it as processed. So, it shouldn't need any more complexity.
* How long do I need the data to persist for? If you only need it to stay resident for a short while (minutes, hours), sessions might be an option.
Forever would be fine, but I might need a time counter for the Who's online list so it know when to kick some user off if they don't do anything after a while. (I'm going to make lots of duplicates of these pages and use each page to hold a different variable. Like have a page for each user. And one to record all chat.)
* What sort of performance / requests per second do I need to be able to handle? If you expect low traffic, you could use a file on the disk to store the variable. If you need a higher volume, I would use a database.
It's going to be real time, so maybe a performance of 1/4 of a second or less.

Also, is there a way to make a php page that creates another php page? Like go to this page:
http://www.example.com/gmmmo/createphppage.php "-d m=" & pagename
and if would create that page with the name of "pagename" which would have the ability to be written on and read just like the other page I described.


Thanks, :)
-Gandolf
GandolfMatt
Forum Newbie
Posts: 5
Joined: Fri Aug 08, 2008 1:45 pm

Re: Php to store variables

Post by GandolfMatt »

Scrap that idea. I figured something that would be way easier and be better all the way around.

I'm learning php and I just need to make a mysql database that will store variables into it when you declare the variable by going to this page:
http://www.example.com/gmmmo/createvariable.php "-d m=" & variablename & "-d m=" & variabledata

It will stick the data into the database. Than I can read it by going to this page:
http://www.example.com/gmmmo/readvariable.php "-d m=" & variablename

Which will display the variable as plain text.

Anyone have any tips or guides? I'm new to this and will try to make this myself.


-Gandolf
Post Reply