CODE
<?
$texture = $_POST["texture"];
echo $texture;
?>
I have this as a running php script on my webserver but i want the texture to stay the same until i define another one just like a global in LSL.
How do i do this in PHP?
These forums are CLOSED. Please visit the new forums HERE
How would i keep a value in php? |
|
|
Ginge Reymont
Registered User
Join date: 10 Oct 2005
Posts: 190
|
08-08-2006 02:40
CODE
I have this as a running php script on my webserver but i want the texture to stay the same until i define another one just like a global in LSL. How do i do this in PHP? |
|
Marcuw Schnook
Scripter
Join date: 24 Dec 2005
Posts: 246
|
08-08-2006 03:08
From head...
CODE
_POST variables can be empty, so when no form is posted, the old value would be erased; testing it before setting would assure that you only get the new texture if one actually was supplied. |
|
Ginge Reymont
Registered User
Join date: 10 Oct 2005
Posts: 190
|
08-08-2006 03:15
Thanks for the quick response but that is wiped after the echo, would the only way to do this be to store it in a mysql database or can php have global variables that dont change unless defined..?
|
|
Marcuw Schnook
Scripter
Join date: 24 Dec 2005
Posts: 246
|
08-08-2006 05:44
Thanks for the quick response but that is wiped after the echo, would the only way to do this be to store it in a mysql database or can php have global variables that dont change unless defined..? I'm not sure what you mean with wiped after the echo... If you use it in multiple pages, use this piece in 1 php file and used the #include statement to include that php file. |
|
Dragon Keen
Registered User
Join date: 24 Apr 2006
Posts: 245
|
08-08-2006 06:09
yes you'd have to store it somewhere
everytime your script calls the php file, its brand new, and the variable isnt stored like you want. You have to call it and save the data somewhere (file/database) then with subsequent calls, get the info from the file/database |
|
Marcuw Schnook
Scripter
Join date: 24 Dec 2005
Posts: 246
|
08-08-2006 14:11
yes you'd have to store it somewhere everytime your script calls the php file, its brand new, and the variable isnt stored like you want. You have to call it and save the data somewhere (file/database) then with subsequent calls, get the info from the file/database Not true. You can have persistent data with php... I've done it with menu systems before... |
|
Azurei Ash
The Sticky!
Join date: 12 Jan 2006
Posts: 38
|
08-08-2006 14:26
How do you do you keep track of the persistent data then, Marcuw? It's not very helpful if you don't explain.
I just use databases myself, that's seemingly what they're for. ~Az |
|
Danae Darkes
Registered User
Join date: 22 May 2006
Posts: 11
|
08-08-2006 15:16
Well, you could use a session, or a cookie, or write it to a flat file, but I agree Az.. database is my preference. PHP, unlike LSL, is not a state system. When a PHP script finishes executing the variables no longer exist in memory.
|
|
Dragon Keen
Registered User
Join date: 24 Apr 2006
Posts: 245
|
08-08-2006 18:31
Not true. You can have persistent data with php... I've done it with menu systems before... like Azurei said... post an example. I just googled persistent data with PHP and the only solutions i've found are outputting data (flat file or database) |
|
Don Misfit
Registered User
Join date: 1 Jun 2006
Posts: 60
|
08-08-2006 19:56
Well... depending on the web server environment, you could store data in a server-side variable (with Windows and IIS, it's called an Application variable).
|
|
Marcuw Schnook
Scripter
Join date: 24 Dec 2005
Posts: 246
|
08-09-2006 07:44
like Azurei said... post an example. I just googled persistent data with PHP and the only solutions i've found are outputting data (flat file or database) As Danae said: Cookies in PHP In PHP there are functions for setting cookies (i.e. sending them to the browser) and the cookie values received from the browser are available via "built-in" PHP array. It is important to note that PHP associates name/value pairs with cookies. To set a cookie is very simple and uses the PHP function setcookie(). Like most PHP functions this has several optional parameters, the first two are the name and the associated value. For example. setcookie("totals",23); The meaning is quite obvious. Retrieving incoming cookies is rather different. The complete set of name/value pairs is available in the array $HTTP_COOKIE_VARS which can be indexed by the name associated with the particular required value. For example. $HTTP_COOKIE_VARS["totals"] So, please learn to google: "php persistent" gave me http://www.phptr.com/articles/article.asp?p=24592&seqNum=3&rl=1 then googleing for "php cookie" brought me: http://www.scit.wlv.ac.uk/~jphb/php/phpdA.html As a scripter/programmer it's a lifesafer to know how to use Internet's resources. NOTE: And seeing this code back, that is what I've been using in my PHP past... |
|
Bitzer Balderdash
Dazed and Confused
Join date: 21 Dec 2005
Posts: 246
|
08-09-2006 07:53
Does llHttpRequest actually honour cookie sets???????????
If so, what is the scope of them? per script? Per sim? per owner? |
|
Paul Churchill
Pie are squared
Join date: 8 Sep 2005
Posts: 53
|
08-09-2006 08:14
depending on circumstances, setup, OS, webserver etc - I have achieved this with Shared Memory in the past.
go to www.zend.com/manual and click to the Shared Memory functions section. HTH. Paul. _____________________
If there are two ways to interpret something I've said and one of them offends or upsets you, I meant the other one.
|
|
Ginge Reymont
Registered User
Join date: 10 Oct 2005
Posts: 190
|
08-09-2006 11:06
Thanks for the input everyone, the cookies was a no go, and yes i do know how to use google as i had been doing for hours before i posted along with going through PHP.net to see if i could learn PHP..
I decided to go with the database approach and thanks to Xavior Nicholas for showing me some php scripts ![]() |
|
Zarf Vantongerloo
Obscure Resident
Join date: 22 Jun 2005
Posts: 110
|
08-21-2006 19:58
LSL's LLHTTPRequest does not support cookies.
In most PHP environments, you need to explicitly store data in the file system or a database if you want information to persist from one HTTP request to the next. Zero Linden's open source Silo script (see 119570) does just that in PHP. Look at it for examples of how, or just use it, since it can be used as a general purpose data store. |