View Single Post
Old 12-15-2012, 08:50 PM   PM User | #16
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,498
Thanks: 44
Thanked 439 Times in 428 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Quote:
Originally Posted by doubledee View Post
Where the problem exists is that while I can populate some array with all 50 PM's when my script first runs (e.g. $testArray), when the user submits the Form, any values in my array get erased.
Thats because the script has stopped running and it's variables are lost (thats the way PHP works I'm afraid - not the same as a windows program). When you submit the form the script runs as a fresh instance with its own memory and variables. Thats the way PHP works and why most people use sessions between scripts being executed to store temporary memory.

Quote:
Originally Posted by doubledee View Post
So I figured that if I could pass the entire array back via the $_POST array, then I could continue to use $testArray, and use all 50 values in it to run my UPDATE and thus mark all 50 PM's as "Unread", if you follow me?!
Yes I've followed that all along and yes there is nothing wrong with doing it that way if thats the way you're happy with it. We've shown you several suitable ways for you to achieve that, it's just a case of you picking what you think is best for you.

Quote:
Originally Posted by AndrewGSW View Post
I assume you are referring to JS stringify() and parse()?
No I was talking about the php functions. I don't do front end design or javascript


Quote:
Originally Posted by AndrewGSW View Post
Serializing in PHP is intended to serialize objects..?
Actually I wasn't aware that you could serialize objects. As far as I was aware it only applied to variables such as arrays, strings, numbers etc so thats news to me!
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote