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
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