Re: [PHP] SESSION array problems [ANOTHER SOLUTION]
register_globals has been deprecated as of PHP6. So writing PHP code to work without global registering not just prevents variable poisoning, it also increases the life span of your scripts. I still wonder if using php_flag register_globals off in .htaccess might affect servers running PHP4 and using safe mode as in ... http://forum.mamboserver.com/showthread.php?t=44514 A yeti -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [ANOTHER SOLUTION]
Hi gang: While this may be trivial to many of you, I post this for the others. In my last problem, which was caused by register globals being ON, I wondered how I could fix this. In my specific case, the client had Register Globals ON and his host objected to turning if OFF saying that other scripts might break. After hearing that, the client was not willing to risk it. So, I looked at some of my older scripts and found I had used: ini_set( 'register_globals', '0' ); But in my last problem, neither '0' or 'off' did anything. So, I looked at the manuals again: http://www.php.net/manual/en/ini.php The manual says, I can change this directive: Entry can be set in php.ini, .htaccess or httpd.conf So, by simply adding an .htaccess file with the following -- php_flag register_globals off -- fixed the problem. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [SOLVED]
That's lazyness, reply all does that by itself. Luke Slater Defiance.bounceme.net/blog/ On 2 Oct 2008, at 16:15, Daniel Brown [EMAIL PROTECTED] wrote: On Thu, Oct 2, 2008 at 11:11 AM, Jay Moore [EMAIL PROTECTED] wrote: Now, someone show me where that is documented? http://us3.php.net/register_globals offtopic rant Also, for the love of glaven, people. If you're going to post to the list, you don't have to include the original sender as well. There's a pretty good chance if they originally posted to the list, they'll see your reply. No need to give them the message twice. /offtopic rant Yes. -- /Daniel P. Brown More full-root dedicated server packages: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Intel 2.4GHz/320/GB/1GB/3TB $74.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] SESSION array problems
On 01 October 2008 21:24, tedd advised: At 2:38 PM -0500 10/1/08, Afan Pasalic wrote: main reason - if you sort by first or last name you will lose index. this way is index always linked to first/last name. Your point is well taken, but I'm not sorting this. True, the arrays have a common index, which is 0, 1, 2, 3 ... [user_id] = Array ( [0] = 6156 [1] = 7030 [2] = 656 ) [first_name] = Array ( [0] = Diane [1] = Fred [2] = Helen ) [last_name] = Array ( [0] = Cable [1] = Cago [2] = Cahalan But the data is relational, such as: Diane Cable has user id 6156. I collected the data like this (in a loop): $_SESSION['user_id'][] = $value; $_SESSION['first_name'][] = $first_name; $_SESSION['last_name'][] = $last_name; Doing this is fine -- the index is automatic. I thought I could retrieve the data by using: $num_users = count($_SESSION['user_id']); // --- this works (correct $num_users) for ($i = 0; $i $num_users; $i++) { $last_name = $_SESSION['last_name'][$i]; $first_name = $_SESSION['first_name'][$i]; echo(trtd$last_name/tdtd$first_name/td/tr); } But that doesn't work. What's really odd is only the first loop works. I'm thinking register_globals here. In every example you've posted, you've used $last_name and $_SESSION['last_name'] -- but these are the same thing if register_globals is on, and would lead to your posted output with the single characters on the 2nd iteration and nothing after that! At least one posted suggestion used $first and $last rather than $first_name and $last_name -- did you actually try with the shorter names, or stick with your longer matching ones? Cheers! Mike -- Mike Ford, Electronic Information Developer, C507, Leeds Metropolitan University, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [SOLVED]
Hi gang: As strange as it may seem, but when session variables are passed to another page (i.e., used) you cannot extract ALL OF THEM using a loop when the variable names you are using are the same as the SESSION index's names. In other words, you cannot do this: for ($i = 0; $i $num_users; $i++) { $last_name = $_SESSION['last_name'][$i]; $first_name = $_SESSION['first_name'][$i]; echo(p$last_name $first_name/p); } But you can do this: for ($i = 0; $i $num_users; $i++) { $last = $_SESSION['last_name'][$i]; $first = $_SESSION['first_name'][$i]; echo(p$last $first/p); } See the difference? This was a crazy one. Now, someone show me where that is documented? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [SOLVED]
On Thu, Oct 2, 2008 at 11:02 AM, tedd [EMAIL PROTECTED] wrote: As strange as it may seem, but when session variables are passed to another page (i.e., used) you cannot extract ALL OF THEM using a loop when the variable names you are using are the same as the SESSION index's names. [snip!] Now, someone show me where that is documented? Is register_globals set to on? -- /Daniel P. Brown More full-root dedicated server packages: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Intel 2.4GHz/320/GB/1GB/3TB $74.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [SOLVED]
tedd wrote: Hi gang: As strange as it may seem, but when session variables are passed to another page (i.e., used) you cannot extract ALL OF THEM using a loop when the variable names you are using are the same as the SESSION index's names. In other words, you cannot do this: for ($i = 0; $i $num_users; $i++) { $last_name = $_SESSION['last_name'][$i]; $first_name = $_SESSION['first_name'][$i]; echo(p$last_name $first_name/p); } But you can do this: for ($i = 0; $i $num_users; $i++) { $last = $_SESSION['last_name'][$i]; $first = $_SESSION['first_name'][$i]; echo(p$last $first/p); } See the difference? This was a crazy one. Now, someone show me where that is documented? Cheers, tedd hm. it doesn't make a sense... -afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [SOLVED]
Now, someone show me where that is documented? http://us3.php.net/register_globals offtopic rant Also, for the love of glaven, people. If you're going to post to the list, you don't have to include the original sender as well. There's a pretty good chance if they originally posted to the list, they'll see your reply. No need to give them the message twice. /offtopic rant Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [SOLVED]
On Thu, Oct 2, 2008 at 11:02 AM, tedd [EMAIL PROTECTED] wrote: Hi gang: As strange as it may seem, but when session variables are passed to another page (i.e., used) you cannot extract ALL OF THEM using a loop when the variable names you are using are the same as the SESSION index's names. In other words, you cannot do this: for ($i = 0; $i $num_users; $i++) { $last_name = $_SESSION['last_name'][$i]; $first_name = $_SESSION['first_name'][$i]; echo(p$last_name $first_name/p); } But you can do this: for ($i = 0; $i $num_users; $i++) { $last = $_SESSION['last_name'][$i]; $first = $_SESSION['first_name'][$i]; echo(p$last $first/p); } See the difference? This was a crazy one. Now, someone show me where that is documented? Cheers, tedd As several of us have suggested now, it's got to be register_globals. That would make the following blocks of code equivalent: ?php for ($i = 0; $i $num_users; $i++) { $last_name = $_SESSION['last_name'][$i]; $first_name = $_SESSION['first_name'][$i]; echo(p$last_name $first_name/p); } for ($i = 0; $i $num_users; $i++) { $_SESSION['last_name'] = $_SESSION['last_name'][$i]; $_SESSION['first_name'] = $_SESSION['first_name'][$i]; echo(p{$_SESSION['last_name']} {$_SESSION['first_name']}/p); } ? Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [SOLVED]
On Thu, Oct 2, 2008 at 11:11 AM, Jay Moore [EMAIL PROTECTED] wrote: Now, someone show me where that is documented? http://us3.php.net/register_globals offtopic rant Also, for the love of glaven, people. If you're going to post to the list, you don't have to include the original sender as well. There's a pretty good chance if they originally posted to the list, they'll see your reply. No need to give them the message twice. /offtopic rant Yes. -- /Daniel P. Brown More full-root dedicated server packages: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Intel 2.4GHz/320/GB/1GB/3TB $74.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [SOLVED]
On 2 Oct 2008, at 16:11, Jay Moore wrote: Now, someone show me where that is documented? http://us3.php.net/register_globals offtopic rant Also, for the love of glaven, people. If you're going to post to the list, you don't have to include the original sender as well. There's a pretty good chance if they originally posted to the list, they'll see your reply. No need to give them the message twice. If your email server/client is stupid enough not to de-dupe based on message ID why should we take extra steps to accommodate your poor choices? If on the other hand you've got scripts that route messages into folders and that's what's causing you to have multiple copies, fix your rules - it's easier than expecting an entire community of volunteers to change the way they've worked, successfully I should add, for years. I see you're using Thunderbird. I used to use Thunderbird for my mailing lists and never had this problem, so I'm guessing it's something your mail server is doing. Your mail server appears to be Exim which I have very little experience of so I can't help you. Sorry. It's also worth noting that since subscriptions is not required to post to these lists there's no guarantee that the OP will get your reply if you don't include their address. IOW you're asking us to deprive a number of developers seeking assistance of our replies because you can't get your own $%*£ in order. How does that make you feel? /offtopic rant Praise FSM! -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems
Ford, Mike wrote: On 01 October 2008 21:24, tedd advised: At 2:38 PM -0500 10/1/08, Afan Pasalic wrote: main reason - if you sort by first or last name you will lose index. this way is index always linked to first/last name. Your point is well taken, but I'm not sorting this. True, the arrays have a common index, which is 0, 1, 2, 3 ... [user_id] = Array ( [0] = 6156 [1] = 7030 [2] = 656 ) [first_name] = Array ( [0] = Diane [1] = Fred [2] = Helen ) [last_name] = Array ( [0] = Cable [1] = Cago [2] = Cahalan But the data is relational, such as: Diane Cable has user id 6156. I collected the data like this (in a loop): $_SESSION['user_id'][] = $value; $_SESSION['first_name'][] = $first_name; $_SESSION['last_name'][] = $last_name; Doing this is fine -- the index is automatic. I thought I could retrieve the data by using: $num_users = count($_SESSION['user_id']); // --- this works (correct $num_users) for ($i = 0; $i $num_users; $i++) { $last_name = $_SESSION['last_name'][$i]; $first_name = $_SESSION['first_name'][$i]; echo(trtd$last_name/tdtd$first_name/td/tr); } But that doesn't work. What's really odd is only the first loop works. I'm thinking register_globals here. In every example you've posted, you've used $last_name and $_SESSION['last_name'] -- but these are the same thing if register_globals is on, and would lead to your posted output with the single characters on the 2nd iteration and nothing after that! nicely put - that's the one. -- nathan ( [EMAIL PROTECTED] ) { Senior Web Developer php + java + flex + xmpp + xml + ecmascript web development edinburgh | http://kraya.co.uk/ } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [SOLVED]
Daniel Brown wrote: On Thu, Oct 2, 2008 at 11:11 AM, Jay Moore [EMAIL PROTECTED] wrote: Now, someone show me where that is documented? http://us3.php.net/register_globals offtopic rant Also, for the love of glaven, people. If you're going to post to the list, you don't have to include the original sender as well. There's a pretty good chance if they originally posted to the list, they'll see your reply. No need to give them the message twice. /offtopic rant Yes. in gmail you need to hit reply to all as suggested on the php mailing list page (they tell everybody to do it) BUT if you do this in thunderbird when it's set up as a proper newsgroup you get the dup's. -- nathan ( [EMAIL PROTECTED] ) { Senior Web Developer php + java + flex + xmpp + xml + ecmascript web development edinburgh | http://kraya.co.uk/ } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [SOLVED]
Stut wrote: It's also worth noting that since subscriptions is not required to post to these lists there's no guarantee that the OP will get your reply if you don't include their address. IOW you're asking us to deprive a number of developers seeking assistance of our replies because you can't get your own $%*£ in order. How does that make you feel? Why is it that it's not ok to top post, but it's perfectly fine to not subscribe to the list? It's extremely rude and arrogant to post to the list and expect people to respond to you personally. In fact, people get all up in arms if someone requests it. I don't reply-all. If I have an answer that will help someone, I post it to the list. If they can't be bothered to subscribe to see my reply, tough cookies. The question went to the list; the response went to the list. (I feel just fine about this, btw. Thank you for your concern.) I do not believe either my email client or my email server are improperly configured. When you reply all, you are posting to a newsgroup and to an email address -- two completely separate entities. I don't think it's out of the ordinary to expect that I would get multiple copies of the same message in that instance. All that said, it's a matter of group etiquette to do things one way over another (ex: top-posting). Maybe the reply-all etiquette should be re-addressed? Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [SOLVED]
Jay Moore wrote: Stut wrote: It's also worth noting that since subscriptions is not required to post to these lists there's no guarantee that the OP will get your reply if you don't include their address. IOW you're asking us to deprive a number of developers seeking assistance of our replies because you can't get your own $%*£ in order. How does that make you feel? Why is it that it's not ok to top post, but it's perfectly fine to not subscribe to the list? It's extremely rude and arrogant to post to the list and expect people to respond to you personally. In fact, people get all up in arms if someone requests it. I don't reply-all. If I have an answer that will help someone, I post it to the list. If they can't be bothered to subscribe to see my reply, tough cookies. The question went to the list; the response went to the list. (I feel just fine about this, btw. Thank you for your concern.) I do not believe either my email client or my email server are improperly configured. When you reply all, you are posting to a newsgroup and to an email address -- two completely separate entities. I don't think it's out of the ordinary to expect that I would get multiple copies of the same message in that instance. All that said, it's a matter of group etiquette to do things one way over another (ex: top-posting). Maybe the reply-all etiquette should be re-addressed? Jay http://www.php.net/mailing-lists.php Be sure to click Reply-All to reply to list. Clicking Reply will email the author of the message privately. -- nathan ( [EMAIL PROTECTED] ) { Senior Web Developer php + java + flex + xmpp + xml + ecmascript web development edinburgh | http://kraya.co.uk/ } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [SOLVED]
On Thu, Oct 2, 2008 at 12:12 PM, Jay Moore [EMAIL PROTECTED] wrote: Why is it that it's not ok to top post, but it's perfectly fine to not subscribe to the list? It's extremely rude and arrogant to post to the list and expect people to respond to you personally. In fact, people get all up in arms if someone requests it. I don't reply-all. If I have an answer that will help someone, I post it to the list. If they can't be bothered to subscribe to see my reply, tough cookies. The question went to the list; the response went to the list. (I feel just fine about this, btw. Thank you for your concern.) I do not believe either my email client or my email server are improperly configured. When you reply all, you are posting to a newsgroup and to an email address -- two completely separate entities. I don't think it's out of the ordinary to expect that I would get multiple copies of the same message in that instance. All that said, it's a matter of group etiquette to do things one way over another (ex: top-posting). Maybe the reply-all etiquette should be re-addressed? No. -- /Daniel P. Brown More full-root dedicated server packages: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Intel 2.4GHz/320/GB/1GB/3TB $74.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [SOLVED]
On 2 Oct 2008, at 17:12, Jay Moore wrote: Stut wrote: It's also worth noting that since subscriptions is not required to post to these lists there's no guarantee that the OP will get your reply if you don't include their address. IOW you're asking us to deprive a number of developers seeking assistance of our replies because you can't get your own $%*£ in order. How does that make you feel? Why is it that it's not ok to top post, but it's perfectly fine to not subscribe to the list? It's extremely rude and arrogant to post to the list and expect people to respond to you personally. In fact, people get all up in arms if someone requests it. Subscribing to this list is a commitment to receiving a fair amount of email and that should not (IMHO) be required in order to get help. But maybe I'm just too giving. I don't reply-all. If I have an answer that will help someone, I post it to the list. If they can't be bothered to subscribe to see my reply, tough cookies. The question went to the list; the response went to the list. (I feel just fine about this, btw. Thank you for your concern.) I do not believe either my email client or my email server are improperly configured. When you reply all, you are posting to a newsgroup and to an email address -- two completely separate entities. I don't think it's out of the ordinary to expect that I would get multiple copies of the same message in that instance. I see your confusion. This is a *mailing list* with a newsgroup gateway. If you're using it as a newsgroup then you have to accept that you're not using it the way it was meant to be used, and that almost always has side-effects. All that said, it's a matter of group etiquette to do things one way over another (ex: top-posting). Maybe the reply-all etiquette should be re-addressed? One persons etiquette is another persons annoyance and in such cases the majority should (again, IMHO) get their way. Top-posting can destroy the usefulness of one email when taken out of context, as can poor or non-existant quoting. That affects anyone who uses the many archives of this list that exist. Me including your email address in my replies (which I will continue to do - that's what you have to pay to get my advice) affects you and you alone and is simply a result of you subscribing to this mailing list through the newsgroup rather than as a mailing list as FSM intended. Now please get over it and let us return to the subject at hand. That's PHP by the way. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [THE REASON]
At 11:13 AM -0400 10/2/08, Andrew Ballard wrote: As several of us have suggested now, it's got to be register_globals. To all: Yes, register_globals was ON as reported by php-info and that was the problem. I also have other servers where register_globals is OFF and I don't have the problem -- so indeed, that WAS the problem. Thanks all for all your time and effort -- it was interesting. This sure can get frustrating at times. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [THE REASON]
On Thu, Oct 2, 2008 at 12:30 PM, tedd [EMAIL PROTECTED] wrote: I also have other servers where register_globals is OFF and I don't have the problem -- so indeed, that WAS the problem. It's INI_PERDIR, by the way, so you can set it with a local php.ini - or, if httpd.conf permits it, you can use .htaccess. And fear not, Sergeant Sperling register_globals is deprecated and is removed as of PHP6. -- /Daniel P. Brown More full-root dedicated server packages: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Intel 2.4GHz/320/GB/1GB/3TB $74.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [THE REASON]
Daniel Brown wrote: And fear not, Sergeant Sperling register_globals is deprecated and is removed as of PHP6. so long, farewell, bye bye -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [THE REASON]
On Thu, Oct 2, 2008 at 12:57 PM, Jim Lucas [EMAIL PROTECTED] wrote: so long, farewell, bye bye If you say so. Do you realize how many websites are going to break now? ;-P https://www.example.com/secure/shop.php?page=creditcardinfo.php ?php include($page); ? -- /Daniel P. Brown More full-root dedicated server packages: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Intel 2.4GHz/320/GB/1GB/3TB $74.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [THE REASON]
On Oct 2, 2008, at 1:01 PM, Daniel Brown wrote: On Thu, Oct 2, 2008 at 12:57 PM, Jim Lucas [EMAIL PROTECTED] wrote: so long, farewell, bye bye If you say so. Do you realize how many websites are going to break now? ;-P https://www.example.com/secure/shop.php?page=creditcardinfo.php ?php include($page); ? Well then they should hurry up and get 6 out so that we can make alot of money editing people's broken websites! -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [THE REASON]
That's probably a good thing: https://www.example.com/secure/shop.php?page=/etc/passwd ?php include($page); ? :-) Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Daniel Brown wrote: On Thu, Oct 2, 2008 at 12:57 PM, Jim Lucas [EMAIL PROTECTED] wrote: so long, farewell, bye bye If you say so. Do you realize how many websites are going to break now? ;-P https://www.example.com/secure/shop.php?page=creditcardinfo.php ?php include($page); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems reply all
At 11:12 AM -0500 10/2/08, Jay Moore wrote: I don't reply-all. If I have an answer that will help someone, I post it to the list. If they can't be bothered to subscribe to see my reply, tough cookies. The question went to the list; the response went to the list. (I feel just fine about this, btw. Thank you for your concern.) I always reply all and then delete all email addresses except for php-general@lists.php.net. If I don't reply all, then my email (Eudora) will not place a -- At 11:12 AM -0500 10/2/08, Jay Moore wrote: -- at the top of my email and quote the rest. Now, sometimes because of this, I make a mistake and reply to everyone. I have had people on occasion tell me not to do that, which I know. But sometimes, as I tell my wife, I just can't be prefect all the time. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [THE REASON]
On Thu, Oct 2, 2008 at 1:14 PM, Micah Gersten [EMAIL PROTECTED] wrote: That's probably a good thing: https://www.example.com/secure/shop.php?page=/etc/passwd Yeah, it was a joke. -- /Daniel P. Brown More full-root dedicated server packages: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Intel 2.4GHz/320/GB/1GB/3TB $74.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [THE REASON]
At 12:50 PM -0400 10/2/08, Daniel Brown wrote: On Thu, Oct 2, 2008 at 12:30 PM, tedd [EMAIL PROTECTED] wrote: I also have other servers where register_globals is OFF and I don't have the problem -- so indeed, that WAS the problem. It's INI_PERDIR, by the way, so you can set it with a local php.ini - or, if httpd.conf permits it, you can use .htaccess. And fear not, Sergeant Sperling register_globals is deprecated and is removed as of PHP6. -- /Daniel P. Brown The problem will still remain as long as we have clients who don't want to change things. For example, I have on client who is scared to death that if we change anything that all his dated forum software will crater and I can't tell him that it won't. While it's nice to turn register register_globals, safe-mode, magic_quotes, and other such nonsense turned off, we will still have to deal with it on clients servers. So, this little experience for me, while frustrating, was instructional. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [THE REASON]
As was mine. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Daniel Brown wrote: On Thu, Oct 2, 2008 at 1:14 PM, Micah Gersten [EMAIL PROTECTED] wrote: That's probably a good thing: https://www.example.com/secure/shop.php?page=/etc/passwd Yeah, it was a joke. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [THE REASON]
Daniel Brown wrote: On Thu, Oct 2, 2008 at 12:57 PM, Jim Lucas [EMAIL PROTECTED] wrote: so long, farewell, bye bye If you say so. Do you realize how many websites are going to break now? ;-P https://www.example.com/secure/shop.php?page=creditcardinfo.php ?php include($page); ? But, you must admit that your example above shows a very good reason that it SHOULD break! Example... https://www.example.com/secure/shop.php?page=http://www.myhackersite.com/hackerscript.txt ?php include($page); ? hackerscript.txt ?php include 'http://www.myhackersite.com/filemanager.txt'; echo 'If you are including this, just think of everything else I can get to.'; $ob = new filemanager(); $ob-run(); ? -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [SOLVED]
Stut wrote: I see your confusion. This is a *mailing list* with a newsgroup gateway. If you're using it as a newsgroup then you have to accept that you're not using it the way it was meant to be used, and that almost always has side-effects. That being the case, I apologize for my assumptions and retract my statements. Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems [THE REASON]
On Thu, Oct 2, 2008 at 1:53 PM, Jim Lucas [EMAIL PROTECTED] wrote: But, you must admit that your example above shows a very good reason that it SHOULD break! Once again, it was a joke. I thought everyone would've realized that immediately. -- /Daniel P. Brown More full-root dedicated server packages: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Intel 2.4GHz/320/GB/1GB/3TB $74.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SESSION array problems
Hi gang: Apparently, there's something going on here that I don't understand -- this happens far too often these days. Here's a print_r($_SESSION); of the session arrays I'm using: [user_id] = Array ( [0] = 6156 [1] = 7030 [2] = 656 ) [first_name] = Array ( [0] = Diane [1] = Fred [2] = Helen ) [last_name] = Array ( [0] = Cable [1] = Cago [2] = Cahalan The following is how I tried to access the data contained in the $_SESSION arrays: $num_users = count($_SESSION['user_id']); for ($i = 0; $i $num_users; $i++) { $last_name = $_SESSION['last_name'][$i]; $first_name = $_SESSION['first_name'][$i]; echo(p$last_name, $first_name/p); } The only thing that came out correct was the first echo. The remaining echos had no values for $first_name or $last_name. What's happening here? Cheers, tedd PS: I'm open to other suggestions as to how to do this. -- --- http://sperling.com http://ancientstones.com http://earthstones.com
Re: [PHP] SESSION array problems
tedd wrote: Hi gang: Apparently, there's something going on here that I don't understand -- this happens far too often these days. Here's a print_r($_SESSION); of the session arrays I'm using: [user_id] = Array ( [0] = 6156 [1] = 7030 [2] = 656 ) [first_name] = Array ( [0] = Diane [1] = Fred [2] = Helen ) [last_name] = Array ( [0] = Cable [1] = Cago [2] = Cahalan The following is how I tried to access the data contained in the $_SESSION arrays: $num_users = count($_SESSION['user_id']); for ($i = 0; $i $num_users; $i++) { $last_name = $_SESSION['last_name'][$i]; $first_name = $_SESSION['first_name'][$i]; echo(p$last_name, $first_name/p); } The only thing that came out correct was the first echo. The remaining echos had no values for $first_name or $last_name. What's happening here? Cheers, tedd PS: I'm open to other suggestions as to how to do this. hi tedd, if I may suggest this model $_SESSION { [6156] { [first_name]= Diane [last_name] = Cable } [7030] { [first_name]= Fred [last_name]= Cago } [656] { [first_name]= Helen [last_name]= Cahalan } } main reason - if you sort by first or last name you will lose index. this way is index always linked to first/last name. foreach ($_SESSION as $key = $value) { echo $_SESSION[$key]['last_name'].', '.$_SESSION[$key]['first_name'].'br'; } didn't test it, though :-) -afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems
tedd wrote: Hi gang: Apparently, there's something going on here that I don't understand -- this happens far too often these days. Here's a print_r($_SESSION); of the session arrays I'm using: [user_id] = Array ( [0] = 6156 [1] = 7030 [2] = 656 ) [first_name] = Array ( [0] = Diane [1] = Fred [2] = Helen ) [last_name] = Array ( [0] = Cable [1] = Cago [2] = Cahalan The following is how I tried to access the data contained in the $_SESSION arrays: $num_users = count($_SESSION['user_id']); for ($i = 0; $i $num_users; $i++) { $last_name = $_SESSION['last_name'][$i]; $first_name = $_SESSION['first_name'][$i]; echo(p$last_name, $first_name/p); } The only thing that came out correct was the first echo. The remaining echos had no values for $first_name or $last_name. What's happening here? Cheers, tedd PS: I'm open to other suggestions as to how to do this. just tested. works fine $_SESSION = array( '6156' = array( 'first_name'= 'Diane', 'last_name' = 'Cable'), '7030' = array( 'first_name'= 'Fred', 'last_name' = 'Cago'), '656' = array( 'first_name'= 'Helen', 'last_name' = 'Cahalan') ); echo 'pre'; print_r($_SESSION); foreach ($_SESSION as $key = $value) { echo $_SESSION[$key]['last_name'].', '.$_SESSION[$key]['first_name'].'br'; } -afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems
At 2:38 PM -0500 10/1/08, Afan Pasalic wrote: main reason - if you sort by first or last name you will lose index. this way is index always linked to first/last name. Your point is well taken, but I'm not sorting this. True, the arrays have a common index, which is 0, 1, 2, 3 ... [user_id] = Array ( [0] = 6156 [1] = 7030 [2] = 656 ) [first_name] = Array ( [0] = Diane [1] = Fred [2] = Helen ) [last_name] = Array ( [0] = Cable [1] = Cago [2] = Cahalan But the data is relational, such as: Diane Cable has user id 6156. I collected the data like this (in a loop): $_SESSION['user_id'][] = $value; $_SESSION['first_name'][] = $first_name; $_SESSION['last_name'][] = $last_name; Doing this is fine -- the index is automatic. I thought I could retrieve the data by using: $num_users = count($_SESSION['user_id']); // --- this works (correct $num_users) for ($i = 0; $i $num_users; $i++) { $last_name = $_SESSION['last_name'][$i]; $first_name = $_SESSION['first_name'][$i]; echo(trtd$last_name/tdtd$first_name/td/tr); } But that doesn't work. What's really odd is only the first loop works. PLUS, a dump of the SESSION arrays done just before the loop does produce what's shown above. So, the data is there, I'm just not retrieving it. There's something here that I'm not understanding. I always seem to have problems with Multidimensional Arrays -- I think it's my dyslexia kicking in. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems
At 2:43 PM -0500 10/1/08, Afan Pasalic wrote: just tested. works fine $_SESSION = array( '6156' = array( 'first_name'= 'Diane', 'last_name' = 'Cable'), '7030' = array( 'first_name'= 'Fred', 'last_name' = 'Cago'), '656' = array( 'first_name'= 'Helen', 'last_name' = 'Cahalan') ); echo 'pre'; print_r($_SESSION); foreach ($_SESSION as $key = $value) { echo $_SESSION[$key]['last_name'].', '.$_SESSION[$key]['first_name'].'br'; } -afan -afan: That's fine, but that's not the problem. The problem is: $_SESSION['user_id'][] = '6156'; $_SESSION['first_name'][] = 'Diane'; $_SESSION['last_name'][]= 'Cable'; $_SESSION['user_id'][] = '1234'; $_SESSION['first_name'][] = 'Big'; $_SESSION['last_name'][]= 'Ron'; $_SESSION['user_id'][] = '8867'; $_SESSION['first_name'][] = 'Joe'; $_SESSION['last_name'][]= 'Dirt'; Now, how do you retrieve it? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems
tedd wrote: At 2:43 PM -0500 10/1/08, Afan Pasalic wrote: just tested. works fine $_SESSION = array( '6156' = array( 'first_name'= 'Diane', 'last_name' = 'Cable'), '7030' = array( 'first_name'= 'Fred', 'last_name' = 'Cago'), '656' = array( 'first_name'= 'Helen', 'last_name' = 'Cahalan') ); echo 'pre'; print_r($_SESSION); foreach ($_SESSION as $key = $value) { echo $_SESSION[$key]['last_name'].', '.$_SESSION[$key]['first_name'].'br'; } -afan -afan: That's fine, but that's not the problem. The problem is: $_SESSION['user_id'][] = '6156'; $_SESSION['first_name'][] = 'Diane'; $_SESSION['last_name'][]= 'Cable'; $_SESSION['user_id'][] = '1234'; $_SESSION['first_name'][] = 'Big'; $_SESSION['last_name'][]= 'Ron'; $_SESSION['user_id'][] = '8867'; $_SESSION['first_name'][] = 'Joe'; $_SESSION['last_name'][]= 'Dirt'; Now, how do you retrieve it? Cheers, tedd Must be something else in your code or some bad server config, because this works great for me: ?php session_start(); $_SESSION['user_id'][] = '6156'; $_SESSION['first_name'][] = 'Diane'; $_SESSION['last_name'][]= 'Cable'; $_SESSION['user_id'][] = '1234'; $_SESSION['first_name'][] = 'Big'; $_SESSION['last_name'][]= 'Ron'; $_SESSION['user_id'][] = '8867'; $_SESSION['first_name'][] = 'Joe'; $_SESSION['last_name'][]= 'Dirt'; $num_users = count($_SESSION['user_id']); for ($i = 0; $i $num_users; $i++) { $last_name = $_SESSION['last_name'][$i]; $first_name = $_SESSION['first_name'][$i]; echo(p$last_name, $first_name/p); } ? Outputs this: Cable, Diane Ron, Big Dirt, Joe -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems
tedd wrote: At 2:43 PM -0500 10/1/08, Afan Pasalic wrote: just tested. works fine $_SESSION = array( '6156' = array( 'first_name'= 'Diane', 'last_name' = 'Cable'), '7030' = array( 'first_name'= 'Fred', 'last_name' = 'Cago'), '656' = array( 'first_name'= 'Helen', 'last_name' = 'Cahalan') ); echo 'pre'; print_r($_SESSION); foreach ($_SESSION as $key = $value) { echo $_SESSION[$key]['last_name'].', '.$_SESSION[$key]['first_name'].'br'; } -afan -afan: That's fine, but that's not the problem. The problem is: $_SESSION['user_id'][] = '6156'; $_SESSION['first_name'][] = 'Diane'; $_SESSION['last_name'][]= 'Cable'; $_SESSION['user_id'][] = '1234'; $_SESSION['first_name'][] = 'Big'; $_SESSION['last_name'][]= 'Ron'; $_SESSION['user_id'][] = '8867'; $_SESSION['first_name'][] = 'Joe'; $_SESSION['last_name'][]= 'Dirt'; Now, how do you retrieve it? Cheers, tedd tedd, I just copied your code, created your sessions and - it works fine. http://afan.net/tedd.php code: ?php session_start(); $_SESSION['user_id'] = array(6156, 7030, 656); $_SESSION['first_name'] = array('Diane', 'Fred', 'Helen'); $_SESSION['last_name'] = array('Cable', 'Cago', 'Cahalan'); echo 'pre'; print_r($_SESSION); $num_users = count($_SESSION['user_id']); // --- this works (correct $num_users) echo ?: .$num_users.'brtable border=1'; for ($i = 0; $i $num_users; $i++) { $last_name = $_SESSION['last_name'][$i]; $first_name = $_SESSION['first_name'][$i]; echo(trtd$last_name/tdtd$first_name/td/tr); } echo '/table'; I think there is something outside your code. -afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems
On Wednesday 01 October 2008, tedd [EMAIL PROTECTED] sent a missive stating: At 2:43 PM -0500 10/1/08, Afan Pasalic wrote: just tested. works fine $_SESSION = array( '6156' = array( 'first_name'= 'Diane', 'last_name' = 'Cable'), '7030' = array( 'first_name'= 'Fred', 'last_name' = 'Cago'), '656' = array( 'first_name'= 'Helen', 'last_name' = 'Cahalan') ); echo 'pre'; print_r($_SESSION); foreach ($_SESSION as $key = $value) { echo $_SESSION[$key]['last_name'].', '.$_SESSION[$key]['first_name'].'br'; } -afan -afan: That's fine, but that's not the problem. The problem is: $_SESSION['user_id'][] = '6156'; $_SESSION['first_name'][] = 'Diane'; $_SESSION['last_name'][]= 'Cable'; $_SESSION['user_id'][] = '1234'; $_SESSION['first_name'][] = 'Big'; $_SESSION['last_name'][]= 'Ron'; $_SESSION['user_id'][] = '8867'; $_SESSION['first_name'][] = 'Joe'; $_SESSION['last_name'][]= 'Dirt'; Now, how do you retrieve it? I still see an index mixing issue here for you. However, on a side note, why don't you create user objects and then just stick the object(s) in the $_SESSION array? Then just while() loop the session and pull the objects out. Henrik -- Henrik Hudson [EMAIL PROTECTED] -- God, root, what is difference? Pitr; UF (http://www.userfriendly.org/) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION array problems
tedd wrote: Hi gang: Apparently, there's something going on here that I don't understand -- this happens far too often these days. Here's a print_r($_SESSION); of the session arrays I'm using: [user_id] = Array ( [0] = 6156 [1] = 7030 [2] = 656 ) [first_name] = Array ( [0] = Diane [1] = Fred [2] = Helen ) [last_name] = Array ( [0] = Cable [1] = Cago [2] = Cahalan The following is how I tried to access the data contained in the $_SESSION arrays: $num_users = count($_SESSION['user_id']); for ($i = 0; $i $num_users; $i++) { $last_name = $_SESSION['last_name'][$i]; $first_name = $_SESSION['first_name'][$i]; echo(p$last_name, $first_name/p); } The only thing that came out correct was the first echo. The remaining echos had no values for $first_name or $last_name. What's happening here? Cheers, tedd PS: I'm open to other suggestions as to how to do this. Why don't you echo what you are trying to access for each loop for ($i = 0; $i $num_users; $i++) { print_r($_SESSION['last_name'][$i]); print_r($_SESSION['first_name'][$i]); } Does the above return to you what you would expect? An alternate to what you are doing here would be this. foreach ( $_SESSION['user_id'] AS $i=$id) { print_r($id); print_r($_SESSION['last_name'][$i]); print_r($_SESSION['first_name'][$i]); } How about this? Jim Lucas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SESSION Array problem - possibly different PHP versions?
Hi All, I have a problem that only occurs on our live server and not our local server. It works fine locally. Basically I am using a session array to store values of product colours. A user can add colours to the session array. The session is defined as follows: $_SESSION['color'][$counter] = $color; Obviously the first time we validate and the $counter is set to 0. When more colours are added the $counter variable increments and should increment the value of the array. The colours are added through a popup window. Before I open the popup window I print_r($_SESSION['color']) to view the contents of the array and make sure that they are valid and it is an array. Output is as follows: [color] = Array ( [0] = #339933 [1] = #00 ) etc... Then once the popup opens I do the same print_r And it now shows: [color] = #339933 There fore it isn't an array of colors within the session array. How can PHP change this? Also the strange thing is that locally it works fine but not live. So I am guessing that there is a problem with a certain version of PHP? Also Im not sure what else could be causing this problem? Any ideas or hints would be appreciated. Thanks Kind regards, Angelo Zanetti Application Developer Web: http://www.elemental.co.za -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION Array problem - possibly different PHP versions?
On Mon, Mar 10, 2008 at 9:22 AM, Angelo Zanetti [EMAIL PROTECTED] wrote: There fore it isn't an array of colors within the session array. How can PHP change this? Also the strange thing is that locally it works fine but not live. So I am guessing that there is a problem with a certain version of PHP? From where is the color data coming in to the script, a database? Check to make sure that the array is being populated. Also, you're not attempting to pass the session from your dev box to your live box, are you? -- /Dan Daniel P. Brown Senior Unix Geek ? while(1) { $me = $mind--; sleep(86400); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] SESSION Array problem - possibly different PHP versions?
-Original Message- From: Daniel Brown [mailto:[EMAIL PROTECTED] Sent: 10 March 2008 16:04 To: Angelo Zanetti Cc: php-general@lists.php.net Subject: Re: [PHP] SESSION Array problem - possibly different PHP versions? On Mon, Mar 10, 2008 at 9:22 AM, Angelo Zanetti [EMAIL PROTECTED] wrote: There fore it isn't an array of colors within the session array. How can PHP change this? Also the strange thing is that locally it works fine but not live. So I am guessing that there is a problem with a certain version of PHP? From where is the color data coming in to the script, a database? Check to make sure that the array is being populated. Also, you're not attempting to pass the session from your dev box to your live box, are you? Hi Daniel, thanks for the reply. The system works as follows. There is a colour picker, when a user clicks on a colour then it opens a popup window with the color set as a GET variable. They can then enter the price per colour etc... once done, they save it. It then saves the details to a session. The user then closes the window and it refreshes the parent page which has the colour picker and a listing of selected colours already choosen, after the refresh it shows the array values (print_r) and is correct the first time: [color] = Array ( [0] = #339933 Then if they do the same procedure again, once the popup opens it shows the session variable as: [color] = #339933 But nothing has been done to the SESSION variables since the save, so somehow between the the click and the popup opening something strange is happening. Like I mentioned it works on a local laptop as well as our local server so its strange, I have tried many times closing the browser to ensure all sessions are cleared. Any ideas what might be causing this error? Thanks very much -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] session array
I am creating an array of sessions $_SESSION['results'][] There may be up to 7 and I need to know why do I always get the notice'Undefined index: results in...'? How do I define or initialise the array if it only gets set once the form has been posted (an answer has been given) on the page. Is there a way to count/output (FOR EACH?) a set of session arrays like this? Ta, Ross -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session array
Ross wrote: I am creating an array of sessions $_SESSION['results'][] There may be up to 7 and I need to know why do I always get the notice'Undefined index: results in...'? How do I define or initialise the array if it only gets set once the form has been posted (an answer has been given) on the page. Is there a way to count/output (FOR EACH?) a set of session arrays like this? Before you try to access the $_SESSION['results'] array, do this... if (!isset($_SESSION['results'])) $_SESSION['results'] = array(); As far as counting and outputting a session array there is nothing special about them - they are the same as any other array variable. This means you can use foreach, print_r, var_dump, etc on them. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session array
Ross wrote: I am creating an array of sessions $_SESSION['results'][] always call session_start() before using $_SESSION There may be up to 7 and I need to know why do I always get the notice'Undefined index: results in...'? How do I define or initialise the array if it only gets set once the form has been posted (an answer has been given) on the page. Is there a way to count/output (FOR EACH?) a set of session arrays like if (is_array($_SESSION['results'])) echo 'number of results is ', count($_SESSION['results']); foreach ($_SESSION['results'] as $number = $data) { echo result number $number contains:; var_dump($data); } this? Ta, Ross -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Array Disappears
Richard Lynch wrote: ... Your basic Human Interface principle, which is apparently going to be called Web 2.0 now. :-) lol, that sums it up perfectly. ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Array Disappears
Richard Lynch wrote: I'm thinking the guy who suggested ignore_user_abort(TRUE) is just doing Voodoo Programming :-) It may or may not be something you want, but I doubt it will have any affect whatsoever on your posted problem. Actually, I think anywhere that somebody thinks they need ignore_user_abort, they probably should re-structure the application to handle the long-running process in a cron job or some other asynchronous manner, rather than try to keep a script running tied to an HTTP connection that isn't useful anymore. In other words: Move the long-running slow heavy lifting computation OUT of the web page generation part, so that your user gets a web page super fast in the first place, and so the long-running part can get done later, when the user isn't stuck waiting around for it. Your basic Human Interface principle, which is apparently going to be called Web 2.0 now. :-) On Mon, April 24, 2006 9:09 pm, Webmaster wrote: Hello, Thank you for the reply. Interesting function. I have not heard of that one previously. I've read the manual pages for it.If I understand ignore_user_abort(TRUE)...you are thinking that maybe the user is being disconnected (using stop button or having ISP issues) prior to the script finishing and therefore the script does not have a chance to create the array? I'm wondering if that would be true, since later in the same script, it generates an email to inform me someone's submission was lost because the array did not exist. I'm confused how it could stop executing the middle of the script (step 4a and 5 below) but yet execute the end of the script (the final step in the code below)? I was first made aware of this issue because of the email, so I think the end of the script is executing. Thanks, R Al wrote: add a ignore_user_abort(TRUE) first thing in your code. Hello, The site I'm working on works like this... Requires a login that uses sessions to remember username and email address. Upon being verified, the user is presented with a page that displays several questions regarding their background. Upon submitting the background page, a script checks to make sure all background questions were answered. If not, the page is redisplayed with a warning to answer all questions. If they are all present, a second page is displayed asking about a specific topic. Submitting the second page calls up the code provided below. In reading the www.php.net/manual/en/ref.session.php page, I'd like to point out we do not use cookies. The session id is propagated in the URL (although it's not visible in the URL bar). Also, session.gc_maxlifetime is set to 5400. We are using PHP 4.3.4. Not very often, but once in a while, I'll get an email warning me that a submission was denied because $_SESSION['Q'] is empty. I'm wondering, hoping and/or praying that someone out there can look at this small script and let me know if I'm doing something wrong with the built in function array_pop, perhaps I don't understand sessions at all or perhaps it is a server issue. It's very confusing because other session variables (name and email from the login page) are not emptied, just $_SESSION['Q']. Here's my code with some documentation: ?php /* $_SESSION['startQA'] contains 11 elements and is generated by a previous page in the site. Once the visitor clicks the page two submit button, the above SESSION variable comes into play again. This script takes that array of elements and does the following: 1. Assign session array to local array 2. Removes the last elemental value using array_pop 3. Removes the last elemental value using array_pop 4. Assign local variable the value of the a POST element 4a. Create a new session array and populates the first element equal to POST element 5. Runs through and populates the remaining 9 elements 5a. Total of 10 elements are now populated, 0 thru 9 6. Double checks the existence of each element 6a. if an element is missing, email me a warning and end program */ //Assign Session array to local variable // Step 1 $thisQarray = $_SESSION['startQA']; //Remove the last element of the original array // Step 2 $area = array_pop($thisQarray); //Remove last element of bgq array and assign to taking_test_at // Step 3 $from_location = array_pop($thisQarray); //Assign test version to variable // Step 4 $testVersion = $_POST['version']; //Start building the final Session Array // Step 4a $_SESSION['Q'] = array($testVersion); //Populate rest of Session Array // Step 5 for ($newBGQCounter=0; $newBGQCountercount($thisQarray); $newBGQCounter++) { $_SESSION['Q'][$newBGQCounter+1] = $thisQarray[$newBGQCounter]; } //test for existense of session array elements if ( ($_SESSION['Q'][0] == ) OR ($_SESSION['Q'][1] == ) OR ($_SESSION['Q'][2] == ) OR ($_SESSION['Q'][3] == ) OR ($_SESSION['Q'][4] == ) OR ($_SESSION['Q'][5] == ) OR ($_SESSION['Q'][6] == ) OR ($_SESSION['Q'][7] == ) OR ($_SESSION['Q'][8] == ) OR ($_SESSION['Q'][9] == ) ) { SEND ME AN
Re: [PHP] Session Array Disappears
Hello, Thank you for the reply. Richard Lynch wrote: On Mon, April 24, 2006 2:48 pm, Webmaster wrote: In reading the www.php.net/manual/en/ref.session.php page, I'd like to point out we do not use cookies. The session id is propagated in the URL (although it's not visible in the URL bar). Something is very odd here... Unless the session data is being passed as an INPUT TYPE=hidden in a FORM, it has to be in the URL to work. It should be visible in the URL bar if it's in the URL. Though, obviously, the thing works, so it's not your problem here... It's just something you should investigate for your own learning experience, rather than to solve your problem today. I apologize, I should have been more clear, and I should have thought a little more before describing the situation. Users navigate from page to page by use of a form method=POST submit button. They do not use a href links to go from page to page. Not very often, but once in a while, I'll get an email warning me that a submission was denied because $_SESSION['Q'] is empty. I'm wondering, //Start building the final Session Array // Step 4a $_SESSION['Q'] = array($testVersion); //Populate rest of Session Array // Step 5 for ($newBGQCounter=0; $newBGQCountercount($thisQarray); $newBGQCounter++) { $_SESSION['Q'][$newBGQCounter+1] = $thisQarray[$newBGQCounter]; } This is the source of your troubles. Step 4a is pointless. Try this in a small test file: ?php $anything['Q'] = 'x'; $anything['Q'][1] = 'y; print_r($anything); ? Per your suggestions, here's a couple of tests I ran and the results I received: ?php session_start(); $testVariable = 'a'; $_SESSION['test'] = array($testVariable); $_SESSION['test'][1] = 'b'; print_r($_SESSION['test']); ? Results: Array ( [0] = a [1] = b ) (desired result, basically what I'm using now) ?php session_start(); $testVariable = 'a'; $_SESSION['test'] = $testVariable; $_SESSION['test'][1] = 'b'; print_r($_SESSION['test']); ? Results: ab (treats it like a string instead of an array, undesired result) ?php session_start(); $testVariable = 'a'; $_SESSION['test'][0] = array($testVariable); $_SESSION['test'][1] = 'b'; print_r($_SESSION['test']); ? Results: Array ( [0] = Array ( [0] = a ) [1] = b ) (creates multi-dimensional array, undesired result) ?php session_start(); $testVariable = '1'; $_SESSION['test'][0] = $testVariable; $_SESSION['test'][1] = '2'; print_r($_SESSION['test']); ? Results: Array ( [0] = 1 [1] = 2 ) (desired result) According to these tests, I could use the first example or the last example to achieve the desired results. //test for existense of session array elements if ( ($_SESSION['Q'][0] == ) OR ($_SESSION['Q'][1] == ) OR ($_SESSION['Q'][2] == ) OR ($_SESSION['Q'][3] == ) OR ($_SESSION['Q'][4] == ) OR ($_SESSION['Q'][5] == ) OR ($_SESSION['Q'][6] == ) OR ($_SESSION['Q'][7] == ) OR ($_SESSION['Q'][8] == ) OR ($_SESSION['Q'][9] == ) ) { SEND ME AN ERROR EMAIL It might be a Good Idea for this error email to dump out ALL of $_SESSION['Q'] as well as all the variables you think are involved in your problem. You would then be able to backtrack and debug this issue in the future. I agree. I actually realized this yesterday after I sent my email to the list. I'm in the process of adjusting the code to include variables in the email. Thank you for the suggestion(s). They are greatly appreciated. At this point, here's my logical thinking 1. Occassionaly, the background information session array is missing one or more elements thus an email is generated and the script ends immediately. 2. In the email portion of the script, which is after the array element check, I call other session variables (username, email address) and they are present. 3. Given the above information, I'm inclined to believe that it's got something to do with just the background information session array. 3a. Perhaps array_pop is the problem, it works differently then I thought?.?. 3b. Perhaps the way I construct the session array corrupts it (using a for loop)?.?. 4. Perhaps session variables are not really intended to contain arrays?.?. 5. I'm not sure if any user interactions (web accelerator, ISP issues or Forward/Back/Reload browser buttons) would cause such an issue?.?. Looking at the above list, I can only deal with item 3. I could change my session array code to populate it like this: $_SESSION['Q'][0] = $testVersion; $_SESSION['Q'][1] = $thisQarray[0]; $_SESSION['Q'][2] = $thisQarray[1]; $_SESSION['Q'][3] = $thisQarray[2]; $_SESSION['Q'][4] = $thisQarray[3]; $_SESSION['Q'][5] = $thisQarray[4]; $_SESSION['Q'][6] = $thisQarray[5]; $_SESSION['Q'][7] = $thisQarray[6]; $_SESSION['Q'][8] = $thisQarray[7]; $_SESSION['Q'][9] = $thisQarray[8]; I'm really at a loss and have no idea what else to try other then the above code. Thanks, R -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Array Disappears
Richard Lynch wrote: I'm thinking the guy who suggested ignore_user_abort(TRUE) is just doing Voodoo Programming :-) I love the term Voodoo Programming! I'm guilty of doing it myself. :-) My 2 cents.I could see times when ignore_user_abort(TRUE) could be very handy. I'm wondering though, if it should always be used with some sort of data check to make sure what you are about to commit to a database is not corrupted. It's been my experience that user interaction can really corrupt data. I would hate to force a script to finish if the user caused issues with the expected data. Perhaps everyone uses it in this manner in default (with data checks) and my point is moot. I just don't think ignore_user_abort(TRUE) has anything to do with my current issue since the session variables for the email portion of my script are still populated and I do receive the warning email. Thanks, R -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session Array Disappears
Hello, The site I'm working on works like this... Requires a login that uses sessions to remember username and email address. Upon being verified, the user is presented with a page that displays several questions regarding their background. Upon submitting the background page, a script checks to make sure all background questions were answered. If not, the page is redisplayed with a warning to answer all questions. If they are all present, a second page is displayed asking about a specific topic. Submitting the second page calls up the code provided below. In reading the www.php.net/manual/en/ref.session.php page, I'd like to point out we do not use cookies. The session id is propagated in the URL (although it's not visible in the URL bar). Also, session.gc_maxlifetime is set to 5400. We are using PHP 4.3.4. Not very often, but once in a while, I'll get an email warning me that a submission was denied because $_SESSION['Q'] is empty. I'm wondering, hoping and/or praying that someone out there can look at this small script and let me know if I'm doing something wrong with the built in function array_pop, perhaps I don't understand sessions at all or perhaps it is a server issue. It's very confusing because other session variables (name and email from the login page) are not emptied, just $_SESSION['Q']. Here's my code with some documentation: ?php /* $_SESSION['startQA'] contains 11 elements and is generated by a previous page in the site. Once the visitor clicks the page two submit button, the above SESSION variable comes into play again. This script takes that array of elements and does the following: 1. Assign session array to local array 2. Removes the last elemental value using array_pop 3. Removes the last elemental value using array_pop 4. Assign local variable the value of the a POST element 4a. Create a new session array and populates the first element equal to POST element 5. Runs through and populates the remaining 9 elements 5a. Total of 10 elements are now populated, 0 thru 9 6. Double checks the existence of each element 6a. if an element is missing, email me a warning and end program */ //Assign Session array to local variable // Step 1 $thisQarray = $_SESSION['startQA']; //Remove the last element of the original array // Step 2 $area = array_pop($thisQarray); //Remove last element of bgq array and assign to taking_test_at // Step 3 $from_location = array_pop($thisQarray); //Assign test version to variable // Step 4 $testVersion = $_POST['version']; //Start building the final Session Array // Step 4a $_SESSION['Q'] = array($testVersion); //Populate rest of Session Array // Step 5 for ($newBGQCounter=0; $newBGQCountercount($thisQarray); $newBGQCounter++) { $_SESSION['Q'][$newBGQCounter+1] = $thisQarray[$newBGQCounter]; } //test for existense of session array elements if ( ($_SESSION['Q'][0] == ) OR ($_SESSION['Q'][1] == ) OR ($_SESSION['Q'][2] == ) OR ($_SESSION['Q'][3] == ) OR ($_SESSION['Q'][4] == ) OR ($_SESSION['Q'][5] == ) OR ($_SESSION['Q'][6] == ) OR ($_SESSION['Q'][7] == ) OR ($_SESSION['Q'][8] == ) OR ($_SESSION['Q'][9] == ) ) { SEND ME AN ERROR EMAIL END PROGRAM } ? Thank you all very much, R -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session Array Disappears
You're missing the session_start() call at the beginning of your code. I'm surprised it works at all without that.. http://www.php.net/manual/en/ref.session.php http://www.php.net/manual/en/function.session-start.php Brady -Original Message- From: Webmaster [mailto:[EMAIL PROTECTED] Sent: Monday, April 24, 2006 1:49 PM To: php-general@lists.php.net Subject: [PHP] Session Array Disappears Hello, The site I'm working on works like this... Requires a login that uses sessions to remember username and email address. Upon being verified, the user is presented with a page that displays several questions regarding their background. Upon submitting the background page, a script checks to make sure all background questions were answered. If not, the page is redisplayed with a warning to answer all questions. If they are all present, a second page is displayed asking about a specific topic. Submitting the second page calls up the code provided below. In reading the www.php.net/manual/en/ref.session.php page, I'd like to point out we do not use cookies. The session id is propagated in the URL (although it's not visible in the URL bar). Also, session.gc_maxlifetime is set to 5400. We are using PHP 4.3.4. Not very often, but once in a while, I'll get an email warning me that a submission was denied because $_SESSION['Q'] is empty. I'm wondering, hoping and/or praying that someone out there can look at this small script and let me know if I'm doing something wrong with the built in function array_pop, perhaps I don't understand sessions at all or perhaps it is a server issue. It's very confusing because other session variables (name and email from the login page) are not emptied, just $_SESSION['Q']. Here's my code with some documentation: ?php /* $_SESSION['startQA'] contains 11 elements and is generated by a previous page in the site. Once the visitor clicks the page two submit button, the above SESSION variable comes into play again. This script takes that array of elements and does the following: 1. Assign session array to local array 2. Removes the last elemental value using array_pop 3. Removes the last elemental value using array_pop 4. Assign local variable the value of the a POST element 4a. Create a new session array and populates the first element equal to POST element 5. Runs through and populates the remaining 9 elements 5a. Total of 10 elements are now populated, 0 thru 9 6. Double checks the existence of each element 6a. if an element is missing, email me a warning and end program */ //Assign Session array to local variable // Step 1 $thisQarray = $_SESSION['startQA']; //Remove the last element of the original array // Step 2 $area = array_pop($thisQarray); //Remove last element of bgq array and assign to taking_test_at // Step 3 $from_location = array_pop($thisQarray); //Assign test version to variable // Step 4 $testVersion = $_POST['version']; //Start building the final Session Array // Step 4a $_SESSION['Q'] = array($testVersion); //Populate rest of Session Array // Step 5 for ($newBGQCounter=0; $newBGQCountercount($thisQarray); $newBGQCounter++) { $_SESSION['Q'][$newBGQCounter+1] = $thisQarray[$newBGQCounter]; } //test for existense of session array elements if ( ($_SESSION['Q'][0] == ) OR ($_SESSION['Q'][1] == ) OR ($_SESSION['Q'][2] == ) OR ($_SESSION['Q'][3] == ) OR ($_SESSION['Q'][4] == ) OR ($_SESSION['Q'][5] == ) OR ($_SESSION['Q'][6] == ) OR ($_SESSION['Q'][7] == ) OR ($_SESSION['Q'][8] == ) OR ($_SESSION['Q'][9] == ) ) { SEND ME AN ERROR EMAIL END PROGRAM } ? Thank you all very much, R -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Array Disappears
Thanks for the reply. Sorry, that was a typo in the email. I actually do have session_start(); at the beginning of the scripts. My bad. Thanks, R Brady Mitchell wrote: You're missing the session_start() call at the beginning of your code. I'm surprised it works at all without that.. http://www.php.net/manual/en/ref.session.php http://www.php.net/manual/en/function.session-start.php Brady -Original Message- From: Webmaster [mailto:[EMAIL PROTECTED] Sent: Monday, April 24, 2006 1:49 PM To: php-general@lists.php.net Subject: [PHP] Session Array Disappears Hello, The site I'm working on works like this... Requires a login that uses sessions to remember username and email address. Upon being verified, the user is presented with a page that displays several questions regarding their background. Upon submitting the background page, a script checks to make sure all background questions were answered. If not, the page is redisplayed with a warning to answer all questions. If they are all present, a second page is displayed asking about a specific topic. Submitting the second page calls up the code provided below. In reading the www.php.net/manual/en/ref.session.php page, I'd like to point out we do not use cookies. The session id is propagated in the URL (although it's not visible in the URL bar). Also, session.gc_maxlifetime is set to 5400. We are using PHP 4.3.4. Not very often, but once in a while, I'll get an email warning me that a submission was denied because $_SESSION['Q'] is empty. I'm wondering, hoping and/or praying that someone out there can look at this small script and let me know if I'm doing something wrong with the built in function array_pop, perhaps I don't understand sessions at all or perhaps it is a server issue. It's very confusing because other session variables (name and email from the login page) are not emptied, just $_SESSION['Q']. Here's my code with some documentation: ?php /* $_SESSION['startQA'] contains 11 elements and is generated by a previous page in the site. Once the visitor clicks the page two submit button, the above SESSION variable comes into play again. This script takes that array of elements and does the following: 1. Assign session array to local array 2. Removes the last elemental value using array_pop 3. Removes the last elemental value using array_pop 4. Assign local variable the value of the a POST element 4a. Create a new session array and populates the first element equal to POST element 5. Runs through and populates the remaining 9 elements 5a. Total of 10 elements are now populated, 0 thru 9 6. Double checks the existence of each element 6a. if an element is missing, email me a warning and end program */ //Assign Session array to local variable // Step 1 $thisQarray = $_SESSION['startQA']; //Remove the last element of the original array // Step 2 $area = array_pop($thisQarray); //Remove last element of bgq array and assign to taking_test_at // Step 3 $from_location = array_pop($thisQarray); //Assign test version to variable // Step 4 $testVersion = $_POST['version']; //Start building the final Session Array // Step 4a $_SESSION['Q'] = array($testVersion); //Populate rest of Session Array // Step 5 for ($newBGQCounter=0; $newBGQCountercount($thisQarray); $newBGQCounter++) { $_SESSION['Q'][$newBGQCounter+1] = $thisQarray[$newBGQCounter]; } //test for existense of session array elements if ( ($_SESSION['Q'][0] == ) OR ($_SESSION['Q'][1] == ) OR ($_SESSION['Q'][2] == ) OR ($_SESSION['Q'][3] == ) OR ($_SESSION['Q'][4] == ) OR ($_SESSION['Q'][5] == ) OR ($_SESSION['Q'][6] == ) OR ($_SESSION['Q'][7] == ) OR ($_SESSION['Q'][8] == ) OR ($_SESSION['Q'][9] == ) ) { SEND ME AN ERROR EMAIL END PROGRAM } ? Thank you all very much, R -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Array Disappears
add a ignore_user_abort(TRUE) first thing in your code. Webmaster wrote: Thanks for the reply. Sorry, that was a typo in the email. I actually do have session_start(); at the beginning of the scripts. My bad. Thanks, R Brady Mitchell wrote: You're missing the session_start() call at the beginning of your code. I'm surprised it works at all without that.. http://www.php.net/manual/en/ref.session.php http://www.php.net/manual/en/function.session-start.php Brady -Original Message- From: Webmaster [mailto:[EMAIL PROTECTED] Sent: Monday, April 24, 2006 1:49 PM To: php-general@lists.php.net Subject: [PHP] Session Array Disappears Hello, The site I'm working on works like this... Requires a login that uses sessions to remember username and email address. Upon being verified, the user is presented with a page that displays several questions regarding their background. Upon submitting the background page, a script checks to make sure all background questions were answered. If not, the page is redisplayed with a warning to answer all questions. If they are all present, a second page is displayed asking about a specific topic. Submitting the second page calls up the code provided below. In reading the www.php.net/manual/en/ref.session.php page, I'd like to point out we do not use cookies. The session id is propagated in the URL (although it's not visible in the URL bar). Also, session.gc_maxlifetime is set to 5400. We are using PHP 4.3.4. Not very often, but once in a while, I'll get an email warning me that a submission was denied because $_SESSION['Q'] is empty. I'm wondering, hoping and/or praying that someone out there can look at this small script and let me know if I'm doing something wrong with the built in function array_pop, perhaps I don't understand sessions at all or perhaps it is a server issue. It's very confusing because other session variables (name and email from the login page) are not emptied, just $_SESSION['Q']. Here's my code with some documentation: ?php /* $_SESSION['startQA'] contains 11 elements and is generated by a previous page in the site. Once the visitor clicks the page two submit button, the above SESSION variable comes into play again. This script takes that array of elements and does the following: 1. Assign session array to local array 2. Removes the last elemental value using array_pop 3. Removes the last elemental value using array_pop 4. Assign local variable the value of the a POST element 4a. Create a new session array and populates the first element equal to POST element 5. Runs through and populates the remaining 9 elements 5a. Total of 10 elements are now populated, 0 thru 9 6. Double checks the existence of each element 6a. if an element is missing, email me a warning and end program */ //Assign Session array to local variable // Step 1 $thisQarray = $_SESSION['startQA']; //Remove the last element of the original array // Step 2 $area = array_pop($thisQarray); //Remove last element of bgq array and assign to taking_test_at // Step 3 $from_location = array_pop($thisQarray); //Assign test version to variable // Step 4 $testVersion = $_POST['version']; //Start building the final Session Array // Step 4a $_SESSION['Q'] = array($testVersion); //Populate rest of Session Array // Step 5 for ($newBGQCounter=0; $newBGQCountercount($thisQarray); $newBGQCounter++) { $_SESSION['Q'][$newBGQCounter+1] = $thisQarray[$newBGQCounter]; } //test for existense of session array elements if ( ($_SESSION['Q'][0] == ) OR ($_SESSION['Q'][1] == ) OR ($_SESSION['Q'][2] == ) OR ($_SESSION['Q'][3] == ) OR ($_SESSION['Q'][4] == ) OR ($_SESSION['Q'][5] == ) OR ($_SESSION['Q'][6] == ) OR ($_SESSION['Q'][7] == ) OR ($_SESSION['Q'][8] == ) OR ($_SESSION['Q'][9] == ) ) { SEND ME AN ERROR EMAIL END PROGRAM } ? Thank you all very much, R -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Array Disappears
Hello, Thank you for the reply. Interesting function. I have not heard of that one previously. I've read the manual pages for it.If I understand ignore_user_abort(TRUE)...you are thinking that maybe the user is being disconnected (using stop button or having ISP issues) prior to the script finishing and therefore the script does not have a chance to create the array? I'm wondering if that would be true, since later in the same script, it generates an email to inform me someone's submission was lost because the array did not exist. I'm confused how it could stop executing the middle of the script (step 4a and 5 below) but yet execute the end of the script (the final step in the code below)? I was first made aware of this issue because of the email, so I think the end of the script is executing. Thanks, R Al wrote: add a ignore_user_abort(TRUE) first thing in your code. Hello, The site I'm working on works like this... Requires a login that uses sessions to remember username and email address. Upon being verified, the user is presented with a page that displays several questions regarding their background. Upon submitting the background page, a script checks to make sure all background questions were answered. If not, the page is redisplayed with a warning to answer all questions. If they are all present, a second page is displayed asking about a specific topic. Submitting the second page calls up the code provided below. In reading the www.php.net/manual/en/ref.session.php page, I'd like to point out we do not use cookies. The session id is propagated in the URL (although it's not visible in the URL bar). Also, session.gc_maxlifetime is set to 5400. We are using PHP 4.3.4. Not very often, but once in a while, I'll get an email warning me that a submission was denied because $_SESSION['Q'] is empty. I'm wondering, hoping and/or praying that someone out there can look at this small script and let me know if I'm doing something wrong with the built in function array_pop, perhaps I don't understand sessions at all or perhaps it is a server issue. It's very confusing because other session variables (name and email from the login page) are not emptied, just $_SESSION['Q']. Here's my code with some documentation: ?php /* $_SESSION['startQA'] contains 11 elements and is generated by a previous page in the site. Once the visitor clicks the page two submit button, the above SESSION variable comes into play again. This script takes that array of elements and does the following: 1. Assign session array to local array 2. Removes the last elemental value using array_pop 3. Removes the last elemental value using array_pop 4. Assign local variable the value of the a POST element 4a. Create a new session array and populates the first element equal to POST element 5. Runs through and populates the remaining 9 elements 5a. Total of 10 elements are now populated, 0 thru 9 6. Double checks the existence of each element 6a. if an element is missing, email me a warning and end program */ //Assign Session array to local variable // Step 1 $thisQarray = $_SESSION['startQA']; //Remove the last element of the original array // Step 2 $area = array_pop($thisQarray); //Remove last element of bgq array and assign to taking_test_at // Step 3 $from_location = array_pop($thisQarray); //Assign test version to variable // Step 4 $testVersion = $_POST['version']; //Start building the final Session Array // Step 4a $_SESSION['Q'] = array($testVersion); //Populate rest of Session Array // Step 5 for ($newBGQCounter=0; $newBGQCountercount($thisQarray); $newBGQCounter++) { $_SESSION['Q'][$newBGQCounter+1] = $thisQarray[$newBGQCounter]; } //test for existense of session array elements if ( ($_SESSION['Q'][0] == ) OR ($_SESSION['Q'][1] == ) OR ($_SESSION['Q'][2] == ) OR ($_SESSION['Q'][3] == ) OR ($_SESSION['Q'][4] == ) OR ($_SESSION['Q'][5] == ) OR ($_SESSION['Q'][6] == ) OR ($_SESSION['Q'][7] == ) OR ($_SESSION['Q'][8] == ) OR ($_SESSION['Q'][9] == ) ) { SEND ME AN ERROR EMAIL END PROGRAM } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Array Disappears
On Mon, April 24, 2006 2:48 pm, Webmaster wrote: In reading the www.php.net/manual/en/ref.session.php page, I'd like to point out we do not use cookies. The session id is propagated in the URL (although it's not visible in the URL bar). Something is very odd here... Unless the session data is being passed as an INPUT TYPE=hidden in a FORM, it has to be in the URL to work. It should be visible in the URL bar if it's in the URL. Though, obviously, the thing works, so it's not your problem here... It's just something you should investigate for your own learning experience, rather than to solve your problem today. Not very often, but once in a while, I'll get an email warning me that a submission was denied because $_SESSION['Q'] is empty. I'm wondering, //Start building the final Session Array // Step 4a $_SESSION['Q'] = array($testVersion); //Populate rest of Session Array // Step 5 for ($newBGQCounter=0; $newBGQCountercount($thisQarray); $newBGQCounter++) { $_SESSION['Q'][$newBGQCounter+1] = $thisQarray[$newBGQCounter]; } This is the source of your troubles. Step 4a is pointless. Try this in a small test file: ?php $anything['Q'] = 'x'; $anything['Q'][1] = 'y; print_r($anything); ? You will not see an 'x' in the output anywhere. $anything cannot be a 1-dimensional array and a 2-dimensional array at the same time. You'll need to store the data from Step 4a in some special 2-D place within $_SESSION['Q'] It looks from your code that perhaps $_SESSION['Q'][0] would be an ideal candidate, as you are using $newBGQcounter+1 as an index, and $newBGQcounter starts at 0 and goes to the size of some other array. So you are using 1, 2, 3, 4, ... for the $thisQarray, and you can cram the $testVersion into index 0. On the other hand, it would probably be MUCH better to not try to cram $testVersion and $thisQarray into the same data structure. Maybe what you SHOULD be doing is more like: $_SESSION['testVersion'] = $testVersion; $_SESSION['thisQarray'] = $thisQarray; Then you won't be confusing yourself with what's what in the SESSION data because the names will match up. There is no need to iterate through an array just to copy it into $_SESSION -- you'll have the indices running from 0 instead of from 1, but you really should just get used to that, and if you ever need to print the index out for a human, only change the numbering on output, not on your internal data structures. //test for existense of session array elements if ( ($_SESSION['Q'][0] == ) OR ($_SESSION['Q'][1] == ) OR ($_SESSION['Q'][2] == ) OR ($_SESSION['Q'][3] == ) OR ($_SESSION['Q'][4] == ) OR ($_SESSION['Q'][5] == ) OR ($_SESSION['Q'][6] == ) OR ($_SESSION['Q'][7] == ) OR ($_SESSION['Q'][8] == ) OR ($_SESSION['Q'][9] == ) ) { SEND ME AN ERROR EMAIL It might be a Good Idea for this error email to dump out ALL of $_SESSION['Q'] as well as all the variables you think are involved in your problem. You would then be able to backtrack and debug this issue in the future. END PROGRAM } ? -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Array Disappears
I'm thinking the guy who suggested ignore_user_abort(TRUE) is just doing Voodoo Programming :-) It may or may not be something you want, but I doubt it will have any affect whatsoever on your posted problem. Actually, I think anywhere that somebody thinks they need ignore_user_abort, they probably should re-structure the application to handle the long-running process in a cron job or some other asynchronous manner, rather than try to keep a script running tied to an HTTP connection that isn't useful anymore. In other words: Move the long-running slow heavy lifting computation OUT of the web page generation part, so that your user gets a web page super fast in the first place, and so the long-running part can get done later, when the user isn't stuck waiting around for it. Your basic Human Interface principle, which is apparently going to be called Web 2.0 now. :-) On Mon, April 24, 2006 9:09 pm, Webmaster wrote: Hello, Thank you for the reply. Interesting function. I have not heard of that one previously. I've read the manual pages for it.If I understand ignore_user_abort(TRUE)...you are thinking that maybe the user is being disconnected (using stop button or having ISP issues) prior to the script finishing and therefore the script does not have a chance to create the array? I'm wondering if that would be true, since later in the same script, it generates an email to inform me someone's submission was lost because the array did not exist. I'm confused how it could stop executing the middle of the script (step 4a and 5 below) but yet execute the end of the script (the final step in the code below)? I was first made aware of this issue because of the email, so I think the end of the script is executing. Thanks, R Al wrote: add a ignore_user_abort(TRUE) first thing in your code. Hello, The site I'm working on works like this... Requires a login that uses sessions to remember username and email address. Upon being verified, the user is presented with a page that displays several questions regarding their background. Upon submitting the background page, a script checks to make sure all background questions were answered. If not, the page is redisplayed with a warning to answer all questions. If they are all present, a second page is displayed asking about a specific topic. Submitting the second page calls up the code provided below. In reading the www.php.net/manual/en/ref.session.php page, I'd like to point out we do not use cookies. The session id is propagated in the URL (although it's not visible in the URL bar). Also, session.gc_maxlifetime is set to 5400. We are using PHP 4.3.4. Not very often, but once in a while, I'll get an email warning me that a submission was denied because $_SESSION['Q'] is empty. I'm wondering, hoping and/or praying that someone out there can look at this small script and let me know if I'm doing something wrong with the built in function array_pop, perhaps I don't understand sessions at all or perhaps it is a server issue. It's very confusing because other session variables (name and email from the login page) are not emptied, just $_SESSION['Q']. Here's my code with some documentation: ?php /* $_SESSION['startQA'] contains 11 elements and is generated by a previous page in the site. Once the visitor clicks the page two submit button, the above SESSION variable comes into play again. This script takes that array of elements and does the following: 1. Assign session array to local array 2. Removes the last elemental value using array_pop 3. Removes the last elemental value using array_pop 4. Assign local variable the value of the a POST element 4a. Create a new session array and populates the first element equal to POST element 5. Runs through and populates the remaining 9 elements 5a. Total of 10 elements are now populated, 0 thru 9 6. Double checks the existence of each element 6a. if an element is missing, email me a warning and end program */ //Assign Session array to local variable // Step 1 $thisQarray = $_SESSION['startQA']; //Remove the last element of the original array // Step 2 $area = array_pop($thisQarray); //Remove last element of bgq array and assign to taking_test_at // Step 3 $from_location = array_pop($thisQarray); //Assign test version to variable // Step 4 $testVersion = $_POST['version']; //Start building the final Session Array // Step 4a $_SESSION['Q'] = array($testVersion); //Populate rest of Session Array // Step 5 for ($newBGQCounter=0; $newBGQCountercount($thisQarray); $newBGQCounter++) { $_SESSION['Q'][$newBGQCounter+1] = $thisQarray[$newBGQCounter]; } //test for existense of session array elements if ( ($_SESSION['Q'][0] == ) OR ($_SESSION['Q'][1] == ) OR ($_SESSION['Q'][2] == ) OR ($_SESSION['Q'][3] == ) OR ($_SESSION['Q'][4] == ) OR ($_SESSION['Q'][5] == ) OR ($_SESSION['Q'][6] == ) OR ($_SESSION['Q'][7] == ) OR
[PHP] Session Array using array_pop and array_unshift
Hello, I have an application that occasionally drops a session array element value. Data from the form... $_POST['firstName']; $_POST['lastName']; $_POST['phone']; $_POST['email']; $_POST['cell']; When the form is submitted, the POST variables are checked to make sure they each contain a value. If not, the form is redisplayed and the user is alerted to the missing data. The next step in the process places the data into an array and then assigns the array to a session variable... $userData = array ($_POST['firstName'], $_POST['lastName'], $_POST['phone'], $_POST['email'], $_POST['cell']); $_SESSION['userData'] = $userData; The user then visits some other pages and fills out some more data. At one point, it is necessary to remove the last two elements from the session array. This is achieved by using array_pop... $cellPhone = array_pop($_SESSION['userData']); $emailAddress = array_pop($_SESSION['userData']); And then it is necessary to add a different variable to the beginning of the session array... $userCleared = ok; array_unshift($_SESSION['userData'], $userCleared); Finally, the data is checked again to make sure values exist. At this point, occasionally, one of the element values of the session array is missing. It's never the same one. It seems that, at random, one of the elemental values just goes away. The others are still there. If an element is missing, I receive an email alerting me to this fact. I can think of other ways to handle all of this data, but my question is this...would the current code cause elements to loose their value? Would using a session array AND the array_pop or array_unshift cause this to happen? Has anyone else experienced this sort of occasional anomaly? Thanks, Rog -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Array using array_pop and array_unshift
On Wed, May 11, 2005 4:46 pm, Webmaster said: I have an application that occasionally drops a session array element value. $_SESSION['userData'] = $userData; this to happen? Has anyone else experienced this sort of occasional anomaly? YES! Granted, in my case, it was a short-lived buglet in PHP, and it was more predictable because I was doing the same thing every time, but... Basically, what was happening in MY case was this: $foo = $_SESSION['foo']; This was putting a string reference (which doesn't even exist as a data type in PHP, but that's what it was in reality) into $foo. Then, later, in other processing, I might do: $foo = 'some other value than was was in $foo'; And, POOF! my value in $_SESSION['foo'] was altered! Because $foo was a string reference being passed back from the PHP code that pulled data out of $_SESSION. I filed a bug report at http://bugs.php.net, and it's labeled as fixed in CVS Short term, I just stopped re-using $foo as a variable name. It's entirely POSSIBLE that you have something similar going on. One tell-tale was that doing a var_dump($_SESSION) or var_dump($foo) would show something not un-like: (string X) foo data where X is the string length, instead of just: (string X) foo data The tell-tale presence of is what made me realize that I was somehow getting a string reference and that was messing with my data when I re-used variables. The annoying thing was that this made scrubbing my $_SESSION data difficult -- and I had people telling me that I should be copying stuff out of $_SESSION, but on a shared server, I don't trust $_SESSION data! So I want to copy it out to $foo, and do, say, a regex on it, and compare the result to the original $_SESSION['foo'] and if they don't match, I consider that data hacked/invalid, because I know it's supposed to be the same before/after this Regex. Yet, if the string is a reference, well, then, the Regex applied to the reference was getting applied to the $_SESSION element... Anyway, make a long story short, it was quite confusing and more than a little annoying to be trying to scrub data that was always a reference and kept changing out from under me when I used it. This may NOT be what's happening to you... Or it might be another manifestation of the same buglet. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session Array...
Hey, I am getting something like this: input type=checkbox name='id[loco package]' value=1 I will be getting upto 5 of the above values, Thanks to John Holmes (from this list) I know how to enter it into the database but how do i create a session with the above? The reason why i want to do this is, 1)user picks upto 5 packages to save to his account (done) 2)if the user is already logged in then the insert query is run and all goes well (done) 3) if the user has not logged in then it should be saved as a session and he should be presented with the login screen, after he logs in the insert query should be run from the session data.without the user re-picking the packages(not done) I was able to do the above (point 3) when i was working with a simple array (eg: id[]=1) but am unable to do so when working with the newer one (id[something]=1) Any help appreciated. Thanks, -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session Array...
I am getting something like this: input type=checkbox name='id[loco package]' value=1 I will be getting upto 5 of the above values, Thanks to John Holmes (from this list) I know how to enter it into the database but how do i create a session with the above? The reason why i want to do this is, 1)user picks upto 5 packages to save to his account (done) 2)if the user is already logged in then the insert query is run and all goes well (done) 3) if the user has not logged in then it should be saved as a session and he should be presented with the login screen, after he logs in the insert query should be run from the session data.without the user re-picking the packages(not done) I was able to do the above (point 3) when i was working with a simple array (eg: id[]=1) but am unable to do so when working with the newer one (id[something]=1) Have you tried: $_SESSION['id'] = $id; Since you have register_globals on, I guess you'd use: Session_register(id); maybe... :) ---John W. Holmes... Amazon Wishlist: http://www.amazon.com/o/registry/3BEXC84AB3A5E PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION ARRAY
Ooops, thats right. I should check over before i send i guess. Sorry, Todd $_SESSION is a predefined variable, session_start() session_register('BILLARRAY') should work though :) Keith Vance Vance Consulting LLC www.vanceconsulting.net (206) 355-2399 Try my open source PHP authentication system, Rampart by visiting http://rampart.sourceforge.net/. Commercial support is available at, http://www.vanceconsulting.net/support/. On Fri, 30 Aug 2002, Todd Pasley wrote: What is the proper syntax for storing an array in a session? is it $_SESSION[BILLARRAY]=$ARRAY? Yep, providing youre using session_start() and session_register(_SESSION) you can assign any type of data, just like a regular hash. Todd. - Original Message - From: Randy Johnson [EMAIL PROTECTED] To: phplist [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Friday, August 30, 2002 9:08 AM Subject: [PHP] SESSION ARRAY What is the proper syntax for storing an array in a session? is it $_SESSION[BILLARRAY]=$ARRAY? Randy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SESSION ARRAY
What is the proper syntax for storing an array in a session? is it $_SESSION[BILLARRAY]=$ARRAY? Randy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION ARRAY
What is the proper syntax for storing an array in a session? is it $_SESSION[BILLARRAY]=$ARRAY? Yep, providing youre using session_start() and session_register(_SESSION) you can assign any type of data, just like a regular hash. Todd. - Original Message - From: Randy Johnson [EMAIL PROTECTED] To: phplist [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Friday, August 30, 2002 9:08 AM Subject: [PHP] SESSION ARRAY What is the proper syntax for storing an array in a session? is it $_SESSION[BILLARRAY]=$ARRAY? Randy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION ARRAY
$_SESSION is a predefined variable, session_start() session_register('BILLARRAY') should work though :) Keith Vance Vance Consulting LLC www.vanceconsulting.net (206) 355-2399 Try my open source PHP authentication system, Rampart by visiting http://rampart.sourceforge.net/. Commercial support is available at, http://www.vanceconsulting.net/support/. On Fri, 30 Aug 2002, Todd Pasley wrote: What is the proper syntax for storing an array in a session? is it $_SESSION[BILLARRAY]=$ARRAY? Yep, providing youre using session_start() and session_register(_SESSION) you can assign any type of data, just like a regular hash. Todd. - Original Message - From: Randy Johnson [EMAIL PROTECTED] To: phplist [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Friday, August 30, 2002 9:08 AM Subject: [PHP] SESSION ARRAY What is the proper syntax for storing an array in a session? is it $_SESSION[BILLARRAY]=$ARRAY? Randy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session Array Problems - Please Help
I'm having issues registering and then updating a value for specific items in an array. I've read through the manual and MARC but I can't seem to find the right answer. Here's what I'm trying to do... Basic Backgroung: This is a view cart page. Depending on products that they have selected I pull information from a MySQL database to give details about their product. To do so I have set up a loop (duh) and on each pass of the loop I add information to the session array. Here's the code...it will make more sense... First...I clean the arrays so that I don't have conflicting data...this is done first thing on the page after session_start(); session_start(); session_register('subtotal'); session_unregister('kitem'); session_unregister('kquan'); session_unregister('kscale'); session_unregister('kdetail'); session_unregister('kdriver'); session_unregister('ksponsor'); session_unregister('kcompany'); session_unregister('kprice'); Then comes the loop which adds data to the now empty arrays... for ($index = 0; $index $indexLimit; $index++) //connect and query MySQL database include (connect.php); $result = mysql_query(SELECT * FROM ar LEFT JOIN company on ar.company_id=company.company_id LEFT JOIN scale on ar.scale_id=scale.scale_id WHERE ar.item_number = '.$i[$index].'\n); //sort through results if ($myrow = mysql_fetch_array($result)) { do { if ($quan != 0 $quan != $quan != 0) { //the following vars will be used on the order form as hidden fields. $kitem[$index] = $myrow[item_number]; $kquan[$index] = $quan; $kscale[$index] = $myrow[size]; $kdetail[$index] = $myrow[details]; $kdriver[$index] = $myrow[driver_name]; $ksponsor[$index] = $myrow[sponsor]; $kcompany[$index] = $myrow[value]; $kprice [$index] = $myrow[price]; } } while($myrow = mysql_fetch_array($result)); } And then finally I reset my session variables (arrays) like this... session_register('kitem'); session_register('kquan'); session_register('kscale'); session_register('kdetail'); session_register('kdriver'); session_register('ksponsor'); session_register('kcompany'); session_register('kprice'); I get mixed and varied results...usually the items show up twice or don't show up at all. Please help if you can see anything that is being done wrong. Thanks... -Jordan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session array :-/
$myArray=array(); Is this line getting executed that second time?... Also, I think it's better to register a variable *before* assigning any value to it... Whether this is just coding style or it actually matters, I dunno. -- WARNING [EMAIL PROTECTED] address is not working -- Use [EMAIL PROTECTED] Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] session array :-/
Hi, I'm having trouble with a two dimensional array with sessions. Following is an example of my code which is split between three pages. ### myFunctions.php ### function addToMyArray($newStuff) { global $myArray; $myArray[]=array(id=$newStuff[myId],name=$newStuff[name]); } ### mainPage.php ### session_start(); include(myFunctions.php); $myArray=array(); session_register(myArray); // add some stuff to myArray here to highlight the prob $myArray[]=array(id=1,name=gabby); $myArray[]=array(id=2,name=marla); .. // if conditions meet addToMyArray($HTTP_POST_VARS); // code to open myOtherWindow.php in a new window. // code to submit a form whos action is PHP_SELF ### myOtherWindow.php ### session_start(); // code to display contents of myArray -- Now on first call to addToMyArray() I have three elements two that I added directly and one via the function call. Now if the function gets called again there is still only 3 elements .. two that I added directly and the third one from the latest function call. The element from the first call has simply vanished !!! And that's my problem, why is the element vanishing ??? Thanx, Christian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]