php-general Digest 2 Oct 2008 10:53:45 -0000 Issue 5714
php-general Digest 2 Oct 2008 10:53:45 - Issue 5714 Topics (messages 281353 through 281358): Re: SESSION array problems 281353 by: Nathan Rixham 281355 by: Jim Lucas Re: Questions regarding limits of processes launched bysystem, exec,passthru ... 281354 by: Valentin Schmid - ICSurselva AG Re: store array into session variable and get it back later 281356 by: Stut php server push 281357 by: gkrisz.upcmail.hu 281358 by: Nathan Rixham Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] -- ---BeginMessage--- tedd wrote: At 3:41 PM -0400 10/1/08, tedd wrote: What about: foreach ($_SESSION['user_id'] as $key = $value) { $last = $_SESSION['last_name'][$key]; $first = $_SESSION['first_name'][$key]; echo $last, $first; } Jay: Close, it produced: Array, Array Array, Array Array, Array Cheers, tedd My error, if produced. Cable, Diane a, i While print_r($_SESSION); JUST BEFORE IT produced: [user_id] = Array ( [0] = 6156 [1] = 7030 [2] = 656 ) [first_name] = Array ( [0] = Diane [1] = first name [2] = Helen ) [last_name] = Array ( [0] = Cable [1] = CagoEsogs-temp (forum) [2] = Cahalane ) Now, what wrong with this picture? Cheers, tedd tedd wrote: At 3:41 PM -0400 10/1/08, tedd wrote: What about: foreach ($_SESSION['user_id'] as $key = $value) { $last = $_SESSION['last_name'][$key]; $first = $_SESSION['first_name'][$key]; echo $last, $first; } Jay: Close, it produced: Array, Array Array, Array Array, Array Cheers, tedd My error, if produced. Cable, Diane a, i While print_r($_SESSION); JUST BEFORE IT produced: [user_id] = Array ( [0] = 6156 [1] = 7030 [2] = 656 ) [first_name] = Array ( [0] = Diane [1] = first name [2] = Helen ) [last_name] = Array ( [0] = Cable [1] = CagoEsogs-temp (forum) [2] = Cahalane ) Now, what wrong with this picture? Cheers, tedd in this case.. what's happened is: $_SESSION['first_name'] is a reference to a variable $first (or whatever is in your for loop) $_SESSION['last_name'] is a reference to a variable $last (or whatever is in your for loop) when you've set $last and $first to string's in the for loop it's passed the variable by reference back to $_SESSION['first_name'] and $_SESSION['last_name'] as strings; when it hit's the second iteration on the for loop it now has strings to deal with so uses the $key (holding integer 1 at this stage) as a string offset thus giving you the second character (offset [1]) of the string variables $last/$first. now set to 'cable'/'diane' thus giving you the 'a'/'i'. when it does pass three there is no offset [2] so gives you nothing. *phew* reproduce code! ?php $userids = array('6156','1234','8867'); $first = array('Diane','Big','Joe'); $last = array('Cable','Ron','Dirt'); function save_to_session( ) { global $userids , $first , $last; $_SESSION['user_id'] = $userids; $_SESSION['first_name'] = $first; $_SESSION['last_name']= $last; } save_to_session( ); print_r( $_SESSION ); $num_users = count($_SESSION['user_id']); for ($i = 0; $i $num_users; $i++) { $first = $_SESSION['first_name'][$i]; $last = $_SESSION['last_name'][$i]; echo $last, $first\n; } ? Regards! -- nathan ( [EMAIL PROTECTED] ) { Senior Web Developer php + java + flex + xmpp + xml + ecmascript web development edinburgh | http://kraya.co.uk/ } ---End Message--- ---BeginMessage--- 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
Re: [PHP] store array into session variable and get it back later
On 1 Oct 2008, at 20:42, Per Jessen wrote: Stut wrote: On 1 Oct 2008, at 11:40, Per Jessen wrote: Alain Roger wrote: how can i get the 'name' value for each row in this session stored array ? thx. You haven't stored an array in the session, you've tried to store an object of class CBreadcrumb. Which AFAIK isn't supported. It is supported but you need to be careful about resources in the class. You can handle these gracefully using the __sleep and __wake magic methods. You also need to make sure the class has been loaded before starting the session or have an __autoload defined. Thanks, I was not aware. Very clear and succinct explanation, btw. No worries. I find it best to limit myself to responding quickly, otherwise I get nothing else done! It also forces me to get straight to the point. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php server push
Hi, (i hope this is the right place to ask questions like below) I am trying to use content type 'multipart/x-mixed-replace' to achive server pushing and I have the following piece of code, which works perfectly. /* file.html */ function handleContent(event) { var result = event.target.responseXML; } var xrequest = new XMLHttpRequest(); xrequest.multipart = true; xrequest.open(GET,file.php,true); xrequest.onload = handleContent; xrequest.send(null); /* file.php */ ?php header('Content-type: multipart/x-mixed-replace;boundary=rn9012'); print --rn9012\n; /* With these prints i can generate an event on the browser side. For instance if I would like to wait for sg to happen on the server side i can make an infinite loop and wait. when sg happens i just print the event. */ while (true) { print Content-type: application/xml\n\n; print ?xml version='1.0'?\n; print contentevent1/content\n; print --rn9012\n; flush();ob_flush(); } sleep(5); /* I close the connection with this event. Closing tag: with 2 extra -- */ print Content-type: application/xml\n\n; print ?xml version='1.0'?\n; print contentlast event/content\n; print --rn9012--\n; ? BUT I have to keep an infinite loop on the server side for each clients just to be able to send and event (let's say in every 3rd hour) Is there a way with which i can keep the connection without the infinite loop, and send the event message to the client from a different php file? /* file2.php */ ?php /* this is what i wish */ send_event_toclient(clientid, eventmessage); //clientid: id of the client that i had saved before //i think this id should be sg socket where i can write the output to. ? I hope I cound explain my problem clearly thank you in advance Christian Guttmann -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php server push
[EMAIL PROTECTED] wrote: Hi, (i hope this is the right place to ask questions like below) I am trying to use content type 'multipart/x-mixed-replace' to achive server pushing and I have the following piece of code, which works perfectly. /* file.html */ function handleContent(event) { var result = event.target.responseXML; } var xrequest = new XMLHttpRequest(); xrequest.multipart = true; xrequest.open(GET,file.php,true); xrequest.onload = handleContent; xrequest.send(null); /* file.php */ ?php header('Content-type: multipart/x-mixed-replace;boundary=rn9012'); print --rn9012\n; /* With these prints i can generate an event on the browser side. For instance if I would like to wait for sg to happen on the server side i can make an infinite loop and wait. when sg happens i just print the event. */ while (true) { print Content-type: application/xml\n\n; print ?xml version='1.0'?\n; print contentevent1/content\n; print --rn9012\n; flush();ob_flush(); } sleep(5); /* I close the connection with this event. Closing tag: with 2 extra -- */ print Content-type: application/xml\n\n; print ?xml version='1.0'?\n; print contentlast event/content\n; print --rn9012--\n; ? BUT I have to keep an infinite loop on the server side for each clients just to be able to send and event (let's say in every 3rd hour) Is there a way with which i can keep the connection without the infinite loop, and send the event message to the client from a different php file? /* file2.php */ ?php /* this is what i wish */ send_event_toclient(clientid, eventmessage); //clientid: id of the client that i had saved before //i think this id should be sg socket where i can write the output to. ? I hope I cound explain my problem clearly thank you in advance Christian Guttmann ahh an age old problem; in short you need something like meteor to handle this (a different http server); tbh the http protocol isn't cut out for this. You may want to save some time and look into XMPP with PUB-SUB; it's lightweight permanent client server connection with server push (ignite realtime/jive software do a great XMPP server that's opensource ;) Regards and sorry for the vagueness - there are tonnes of articles everywhere on the net documenting the problems; this is why everybody poll's all the time. if you do want a strictly PHP resolution then look into making your own multiprocess daemon with socket stream server / client and the stream_ functions - rather complicated and not a standard way fo doing things, but fun :) -- 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] db_* = pg_*/my_*/ifx_* ?
uaca man wrote: nathan, if you are not going to help, DON´T answer. [/snip] Angelo, suggesting that there are some classes for this on phpclasses is helping suggesting that a vast amount of articles and resource can easily be located on google is helping suggesting that the issue is also discussed and provision made for within the php manual is also helping. just like mentioning that there's resources on pear. . ps: from the php mailing list rules 3. Do not top post. Place your answer underneath anyone you wish to quote and remove any previous comment that is not relevant to your post. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: SESSION array problems UPDATE
At 11:10 PM +0100 10/1/08, Nathan Rixham wrote: [tested - works] -snip- ? regards! nathan :) I need to re-address this.. tedd your original code works fine over here; as does the code I sent you, and the code jay submitted first.. do us a favour, copy and paste exactly what I just handed through and run it; are the results correct? To all: The code provided by nathan works for me as well. However, the problem is not easily explained, but I can demonstrate it -- try this: http://www.webbytedd.com/zzz/index.php * A complete listing of the code follows the demo. When the code is first loaded, the session variables are defined and populated. Proof of this is shown in the top left corner of the page, which reports: Cable Diane Ron Big Dirt Joe Now click the Continue button and you will be presented with the next step which shows a list of the SESSION variables in both the top left corner AND immediately below Step 2. Everything is righteous to there. However, the next portion of the code is the foreach loop where the first SESSION pair is output correctly, but the rest aren't. This is followed by another listing of the SESSION variables and this time is shows that they have completely disappeared. Okay gang -- what's up with that? Cut and paste the code and see for yourself. 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] Re: SESSION array problems UPDATE
On Thu, Oct 2, 2008 at 10:37 AM, tedd [EMAIL PROTECTED] wrote: To all: The code provided by nathan works for me as well. However, the problem is not easily explained, but I can demonstrate it -- try this: http://www.webbytedd.com/zzz/index.php * A complete listing of the code follows the demo. When the code is first loaded, the session variables are defined and populated. Proof of this is shown in the top left corner of the page, which reports: Cable Diane Ron Big Dirt Joe Now click the Continue button and you will be presented with the next step which shows a list of the SESSION variables in both the top left corner AND immediately below Step 2. Everything is righteous to there. However, the next portion of the code is the foreach loop where the first SESSION pair is output correctly, but the rest aren't. This is followed by another listing of the SESSION variables and this time is shows that they have completely disappeared. Okay gang -- what's up with that? Cut and paste the code and see for yourself. Cheers, tedd tedd, Is there any chance that session variables are getting auto registered? The fact that the second time through the loop is outputting the second letter of each name looks like $first_name is bound to $_SESSION['first_name'] and $last_name is bound to $_SESSION['last_name']. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: SESSION array problems UPDATE
tedd wrote: At 11:10 PM +0100 10/1/08, Nathan Rixham wrote: [tested - works] -snip- ? regards! nathan :) I need to re-address this.. tedd your original code works fine over here; as does the code I sent you, and the code jay submitted first.. do us a favour, copy and paste exactly what I just handed through and run it; are the results correct? To all: The code provided by nathan works for me as well. However, the problem is not easily explained, but I can demonstrate it -- try this: http://www.webbytedd.com/zzz/index.php * A complete listing of the code follows the demo. When the code is first loaded, the session variables are defined and populated. Proof of this is shown in the top left corner of the page, which reports: Cable Diane Ron Big Dirt Joe Now click the Continue button and you will be presented with the next step which shows a list of the SESSION variables in both the top left corner AND immediately below Step 2. Everything is righteous to there. However, the next portion of the code is the foreach loop where the first SESSION pair is output correctly, but the rest aren't. This is followed by another listing of the SESSION variables and this time is shows that they have completely disappeared. Okay gang -- what's up with that? Cut and paste the code and see for yourself. Cheers, tedd Much as it pains me to ask this, you don't have REGISTER_GLOBALS on, do you? Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: SESSION array problems UPDATE
Jay Moore wrote: tedd wrote: At 11:10 PM +0100 10/1/08, Nathan Rixham wrote: [tested - works] -snip- ? regards! nathan :) I need to re-address this.. tedd your original code works fine over here; as does the code I sent you, and the code jay submitted first.. do us a favour, copy and paste exactly what I just handed through and run it; are the results correct? To all: The code provided by nathan works for me as well. However, the problem is not easily explained, but I can demonstrate it -- try this: http://www.webbytedd.com/zzz/index.php * A complete listing of the code follows the demo. When the code is first loaded, the session variables are defined and populated. Proof of this is shown in the top left corner of the page, which reports: Cable Diane Ron Big Dirt Joe Now click the Continue button and you will be presented with the next step which shows a list of the SESSION variables in both the top left corner AND immediately below Step 2. Everything is righteous to there. However, the next portion of the code is the foreach loop where the first SESSION pair is output correctly, but the rest aren't. This is followed by another listing of the SESSION variables and this time is shows that they have completely disappeared. Okay gang -- what's up with that? Cut and paste the code and see for yourself. Cheers, tedd Much as it pains me to ask this, you don't have REGISTER_GLOBALS on, do you? Jay Try these options (separately): 1) Change your first and third entries (so Joe Dirt is 0 and Cable Diane is 2). See if your 2nd output is now '1 o i'. 2) Change your storage variables ($first_name and $last_name) to something other than the key values of your session array (ex: $fname and $lname). See if that works. Jay -- 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] Re: SESSION array problems UPDATE
Much as it pains me to ask this, you don't have REGISTER_GLOBALS on, do you? Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php It must be. I just ran tedd's example in both scenarios. With register_globals = Off it works like a charm. With register_globals = On I get the same output tedd does. register_globals = on: Problem Step 2 -- Cable Diane Ron Big Dirt Joe 0 Cable Diane 1 a i 2 register_globals = Off: Step 2 -- Cable Diane Ron Big Dirt Joe 0 Cable Diane 1 Ron Big 2 Dirt Joe Cable Diane Ron Big Dirt Joe -- Thiago Henrique Pojda Forgot my blog url, php list doesn't like it :) -- Thiago Henrique Pojda Okay, gmail must be playing with me... 3rd email rejected by spammy url -- Thiago Henrique Pojda -- 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] Re: SESSION array problems UPDATE
Andrew Ballard wrote: On Thu, Oct 2, 2008 at 10:37 AM, tedd [EMAIL PROTECTED] wrote: To all: The code provided by nathan works for me as well. However, the problem is not easily explained, but I can demonstrate it -- try this: http://www.webbytedd.com/zzz/index.php * A complete listing of the code follows the demo. When the code is first loaded, the session variables are defined and populated. Proof of this is shown in the top left corner of the page, which reports: Cable Diane Ron Big Dirt Joe Now click the Continue button and you will be presented with the next step which shows a list of the SESSION variables in both the top left corner AND immediately below Step 2. Everything is righteous to there. However, the next portion of the code is the foreach loop where the first SESSION pair is output correctly, but the rest aren't. This is followed by another listing of the SESSION variables and this time is shows that they have completely disappeared. Okay gang -- what's up with that? Cut and paste the code and see for yourself. Cheers, tedd tedd, could you please in foreach loop (on your website) add one echo line: foreach( $_SESSION['user_id'] as $index = $value ) { echo '- '.$index.': '.$value.'br'; $last_name = $_SESSION['last_name'][$index]; $first_name = $_SESSION['first_name'][$index]; echo(p$index $last_name $first_name/p); } thanks -afan -- 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] Re: SESSION array problems UPDATE
tedd wrote: At 11:10 PM +0100 10/1/08, Nathan Rixham wrote: [tested - works] -snip- ? regards! nathan :) I need to re-address this.. tedd your original code works fine over here; as does the code I sent you, and the code jay submitted first.. do us a favour, copy and paste exactly what I just handed through and run it; are the results correct? To all: The code provided by nathan works for me as well. However, the problem is not easily explained, but I can demonstrate it -- try this: http://www.webbytedd.com/zzz/index.php * A complete listing of the code follows the demo. When the code is first loaded, the session variables are defined and populated. Proof of this is shown in the top left corner of the page, which reports: Cable Diane Ron Big Dirt Joe Now click the Continue button and you will be presented with the next step which shows a list of the SESSION variables in both the top left corner AND immediately below Step 2. Everything is righteous to there. However, the next portion of the code is the foreach loop where the first SESSION pair is output correctly, but the rest aren't. This is followed by another listing of the SESSION variables and this time is shows that they have completely disappeared. Okay gang -- what's up with that? Cut and paste the code and see for yourself. Cheers, tedd Well, I would have to say it is a configuration issue on your server. Here is the results for my test with your code. Works fine. http://www.cmsws.com/examples/php/testscripts/[EMAIL PROTECTED]/002.php -- 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]
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] Re: SESSION array problems UPDATE
Jim Lucas wrote: tedd wrote: At 11:10 PM +0100 10/1/08, Nathan Rixham wrote: [tested - works] -snip- ? regards! nathan :) I need to re-address this.. tedd your original code works fine over here; as does the code I sent you, and the code jay submitted first.. do us a favour, copy and paste exactly what I just handed through and run it; are the results correct? To all: The code provided by nathan works for me as well. However, the problem is not easily explained, but I can demonstrate it -- try this: http://www.webbytedd.com/zzz/index.php * A complete listing of the code follows the demo. When the code is first loaded, the session variables are defined and populated. Proof of this is shown in the top left corner of the page, which reports: Cable Diane Ron Big Dirt Joe Now click the Continue button and you will be presented with the next step which shows a list of the SESSION variables in both the top left corner AND immediately below Step 2. Everything is righteous to there. However, the next portion of the code is the foreach loop where the first SESSION pair is output correctly, but the rest aren't. This is followed by another listing of the SESSION variables and this time is shows that they have completely disappeared. Okay gang -- what's up with that? Cut and paste the code and see for yourself. Cheers, tedd Well, I would have to say it is a configuration issue on your server. Here is the results for my test with your code. Works fine. http://www.cmsws.com/examples/php/testscripts/[EMAIL PROTECTED]/002.php With RG off, it works as expected. But, with RG on it gives the results he was seeing. -- 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] Re: SESSION array problems UPDATE
Jim Lucas wrote: Jim Lucas wrote: tedd wrote: At 11:10 PM +0100 10/1/08, Nathan Rixham wrote: [tested - works] -snip- ? regards! nathan :) I need to re-address this.. tedd your original code works fine over here; as does the code I sent you, and the code jay submitted first.. do us a favour, copy and paste exactly what I just handed through and run it; are the results correct? To all: The code provided by nathan works for me as well. However, the problem is not easily explained, but I can demonstrate it -- try this: http://www.webbytedd.com/zzz/index.php * A complete listing of the code follows the demo. When the code is first loaded, the session variables are defined and populated. Proof of this is shown in the top left corner of the page, which reports: Cable Diane Ron Big Dirt Joe Now click the Continue button and you will be presented with the next step which shows a list of the SESSION variables in both the top left corner AND immediately below Step 2. Everything is righteous to there. However, the next portion of the code is the foreach loop where the first SESSION pair is output correctly, but the rest aren't. This is followed by another listing of the SESSION variables and this time is shows that they have completely disappeared. Okay gang -- what's up with that? Cut and paste the code and see for yourself. Cheers, tedd Well, I would have to say it is a configuration issue on your server. Here is the results for my test with your code. Works fine. http://www.cmsws.com/examples/php/testscripts/[EMAIL PROTECTED]/002.php With RG off, it works as expected. But, with RG on it gives the results he was seeing. that explains my earlier post on the matter: in this case.. what's happened is: $_SESSION['first_name'] is a reference to a variable $first (or whatever is in your for loop) $_SESSION['last_name'] is a reference to a variable $last (or whatever is in your for loop) when you've set $last and $first to string's in the for loop it's passed the variable by reference back to $_SESSION['first_name'] and $_SESSION['last_name'] as strings; when it hit's the second iteration on the for loop it now has strings to deal with so uses the $key (holding integer 1 at this stage) as a string offset thus giving you the second character (offset [1]) of the string variables $last/$first. now set to 'cable'/'diane' thus giving you the 'a'/'i'. when it does pass three there is no offset [2] so gives you nothing. *phew* reproduce code! ?php $userids = array('6156','1234','8867'); $first = array('Diane','Big','Joe'); $last = array('Cable','Ron','Dirt'); function save_to_session( ) { global $userids , $first , $last; $_SESSION['user_id'] = $userids; $_SESSION['first_name'] = $first; $_SESSION['last_name']= $last; } save_to_session( ); print_r( $_SESSION ); $num_users = count($_SESSION['user_id']); for ($i = 0; $i $num_users; $i++) { $first = $_SESSION['first_name'][$i]; $last = $_SESSION['last_name'][$i]; echo $last, $first\n; } ? lol to think ti was just register globals - thats why i don't use globals! ps: tedd; you could have got to the bottom of this earlier by having error reporting set to include notices :) -- 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
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] Re: SESSION array problems
Nathan Rixham wrote: tedd wrote: At 3:41 PM -0400 10/1/08, tedd wrote: What about: foreach ($_SESSION['user_id'] as $key = $value) { $last = $_SESSION['last_name'][$key]; $first = $_SESSION['first_name'][$key]; echo $last, $first; } Jay: Close, it produced: Array, Array Array, Array Array, Array Cheers, tedd My error, if produced. Cable, Diane a, i While print_r($_SESSION); JUST BEFORE IT produced: [user_id] = Array ( [0] = 6156 [1] = 7030 [2] = 656 ) [first_name] = Array ( [0] = Diane [1] = first name [2] = Helen ) [last_name] = Array ( [0] = Cable [1] = CagoEsogs-temp (forum) [2] = Cahalane ) Now, what wrong with this picture? Cheers, tedd tedd wrote: At 3:41 PM -0400 10/1/08, tedd wrote: What about: foreach ($_SESSION['user_id'] as $key = $value) { $last = $_SESSION['last_name'][$key]; $first = $_SESSION['first_name'][$key]; echo $last, $first; } Jay: Close, it produced: Array, Array Array, Array Array, Array Cheers, tedd My error, if produced. Cable, Diane a, i While print_r($_SESSION); JUST BEFORE IT produced: [user_id] = Array ( [0] = 6156 [1] = 7030 [2] = 656 ) [first_name] = Array ( [0] = Diane [1] = first name [2] = Helen ) [last_name] = Array ( [0] = Cable [1] = CagoEsogs-temp (forum) [2] = Cahalane ) Now, what wrong with this picture? Cheers, tedd in this case.. what's happened is: $_SESSION['first_name'] is a reference to a variable $first (or whatever is in your for loop) $_SESSION['last_name'] is a reference to a variable $last (or whatever is in your for loop) when you've set $last and $first to string's in the for loop it's passed the variable by reference back to $_SESSION['first_name'] and $_SESSION['last_name'] as strings; when it hit's the second iteration on the for loop it now has strings to deal with so uses the $key (holding integer 1 at this stage) as a string offset thus giving you the second character (offset [1]) of the string variables $last/$first. now set to 'cable'/'diane' thus giving you the 'a'/'i'. when it does pass three there is no offset [2] so gives you nothing. *phew* reproduce code! ?php $userids = array('6156','1234','8867'); $first = array('Diane','Big','Joe'); $last = array('Cable','Ron','Dirt'); function save_to_session( ) { global $userids , $first , $last; $_SESSION['user_id'] = $userids; $_SESSION['first_name'] = $first; $_SESSION['last_name']= $last; } save_to_session( ); print_r( $_SESSION ); $num_users = count($_SESSION['user_id']); for ($i = 0; $i $num_users; $i++) { $first = $_SESSION['first_name'][$i]; $last = $_SESSION['last_name'][$i]; echo $last, $first\n; } ? Regards! This looks like a bug. If you are not modifying a variable with the same name as the session variable, it should not change the session variable. Also, why are you assigning references to arrays? What version of PHP are you using? You really should get up to speed on PHP 5. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- 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
[PHP] Selecting all records between a date range
Hi Everyone, I am working on a app where I need to be able to select all the values from a database where the 'timein' field is between a certain date range... Essentially the last 7 days... here is the code that I am working with: $rangeBegin = strtotime(Last week thursday midnight); $rangeEnd = strtotime(Today now); $SQLTEST = SELECT * FROM `timeStore` WHERE `timein` BETWEEN {$rangeBegin} AND {$rangeEnd}; echo SQLTEST: . $SQLTEST . br; SQLTEST: SELECT * FROM `timeStore` WHERE `timein` BETWEEN 1222315200 AND 122292 Could not perform query: Query was empty All of my times are stored as unix timestamps in the database, such as: +--+ | timein | timeout| empID | record | +++---++ | 1222354037 | 1222382837 | 1 |107 | | 1222440437 | 1222469237 | 1 |108 | | 1222526837 | 1222555637 | 1 |109 | | 1222613237 | 1222642037 | 1 |110 | | 1222699637 | 1222728437 | 1 |111 | | 1222359217 | 1222359220 | 2 |115 | | 1222359214 | 1222359220 | 2 |114 | | 1222359219 | 1222359220 | 2 |116 | | 1222359231 | 1222359566 | 2 |117 | +--+ Anyone has any ideas? Or maybe a better way? :) -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED]
Re: [PHP] Selecting all records between a date range
Jason Pruim wrote: Hi Everyone, I am working on a app where I need to be able to select all the values from a database where the 'timein' field is between a certain date range... Essentially the last 7 days... SELECT * FROM timeStore WHERE timeinDATE_SUB(now(),INTERVAL 7 DAYS) /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Selecting all records between a date range
Jason Pruim wrote: Hi Everyone, Could not perform query: Query was empty This would tell me that the variable that you are passing to your function call is either empty or not set. Maybe a typo. -- 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: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] Selecting all records between a date range
On Oct 2, 2008, at 12:39 PM, Per Jessen wrote: Jason Pruim wrote: Hi Everyone, I am working on a app where I need to be able to select all the values from a database where the 'timein' field is between a certain date range... Essentially the last 7 days... SELECT * FROM timeStore WHERE timeinDATE_SUB(now(),INTERVAL 7 DAYS) Hmmm... To do that, I'd have to store the date/timestamps in a different format... I'll look into this more, but I think I'd have to rewrite the program to make that work. Thanks for the suggestion though! -- 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] Re: SESSION array problems
At 11:14 AM -0500 10/2/08, Micah Gersten wrote: You really should get up to speed on PHP 5. Yeah, I'll be sure to tell me clients that. Sometimes you don't have a choice -- you have to work with what they got. 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] Selecting all records between a date range
On Oct 2, 2008, at 12:46 PM, Jim Lucas wrote: Jason Pruim wrote: Hi Everyone, Could not perform query: Query was empty This would tell me that the variable that you are passing to your function call is either empty or not set. Maybe a typo. Hi Jim, Wouldn't that have shown up in the echo of the statement though? I did double check it and couldn't find any typos listed... -- 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 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] Selecting all records between a date range
On Oct 2, 2008, at 1:17 PM, Jason Pruim wrote: On Oct 2, 2008, at 12:46 PM, Jim Lucas wrote: Jason Pruim wrote: Hi Everyone, Could not perform query: Query was empty This would tell me that the variable that you are passing to your function call is either empty or not set. Maybe a typo. Hi Jim, Wouldn't that have shown up in the echo of the statement though? I did double check it and couldn't find any typos listed... Okay... So the problem was mine... the immediate variables were fine, but when I looked at my while... I saw typos... It's been fixed, sorry for the noise... -- 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]
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] Selecting all records between a date range
What is the actual code that you use to run the query. You've shown us how you set up the query but not more. Something like $result = mysql_query($query,$conn); Robbert On Thu, Oct 2, 2008 at 10:17 AM, Jason Pruim [EMAIL PROTECTED] wrote: On Oct 2, 2008, at 12:46 PM, Jim Lucas wrote: Jason Pruim wrote: Hi Everyone, Could not perform query: Query was empty This would tell me that the variable that you are passing to your function call is either empty or not set. Maybe a typo. Hi Jim, Wouldn't that have shown up in the echo of the statement though? I did double check it and couldn't find any typos listed... -- 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] Selecting all records between a date range
On Thu, Oct 2, 2008 at 12:35 PM, Jason Pruim [EMAIL PROTECTED] wrote: SQLTEST: SELECT * FROM `timeStore` WHERE`timein` BETWEEN 1222315200 AND 122292 Could not perform query: Query was empty [EMAIL PROTECTED] Put a ' around your timestamp numbers. I think that should fix that query. Although I'll admitt, I have no way to test that on mysql, but that is how MS SQL works... -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month. Build a man a fire, and he will be warm for the rest of the day. Light a man on fire, and will be warm for the rest of his life.
Re: [PHP] Selecting all records between a date range
Dan Joseph wrote: On Thu, Oct 2, 2008 at 12:35 PM, Jason Pruim [EMAIL PROTECTED] wrote: SQLTEST: SELECT * FROM `timeStore` WHERE`timein` BETWEEN 1222315200 AND 122292 Could not perform query: Query was empty [EMAIL PROTECTED] Put a ' around your timestamp numbers. I think that should fix that query. Although I'll admitt, I have no way to test that on mysql, but that is how MS SQL works... You mean turn perfectly fine integers into strings??? Why??? -- 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] Selecting all records between a date range
In the original message you were assigning the query to $SQLTEST, but in the code below you're using $sql. On Thu, Oct 2, 2008 at 10:40 AM, Jason Pruim [EMAIL PROTECTED] wrote: On Oct 2, 2008, at 1:31 PM, Robbert van Andel wrote: What is the actual code that you use to run the query. You've shown us how you set up the query but not more. Something like $result = mysql_query($query,$conn); Here is the code I use: $row[]= mysql_query($sql) or die(Could not perform query: .mysql_error()); $result = $row[0]; while ($row = mysql_fetch_assoc($result)){ $timein = date(m/d/y h:i:s, $row['timein']); $timeout = date(m/d/y h:i:s, $row['timeout']); $totalday = ($row['timeout'] - $row['timein']); $totalday = $totalday/60/60; $totalday = round($totalday, 2); $totalWeek += $totalday; // Builds the total from the daily total echo ADMIN tr td{$row['Name']}/td td{$timein}/td td{$timeout}/td td{$totalday}/td /tr ADMIN; } # Display Weekly total echo WEEKTOTAL tr td colspan='4' align='right'TOTAL FOR WEEK: {$totalWeek}/td /tr WEEKTOTAL; echo /table /div /body; Works out really well. Now I just need to show it to the boss, change every possible thing about it, until I hate it and they love it and call it good :) -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED]
Re: [PHP] Re: SESSION array problems
I was referring to Nathan's examples which you cut out of the post. function save_to_session( ) { global $userids , $first , $last; $_SESSION['user_id'] = $userids; $_SESSION['first_name'] = $first; $_SESSION['last_name']= $last; } Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com tedd wrote: At 11:14 AM -0500 10/2/08, Micah Gersten wrote: You really should get up to speed on PHP 5. Yeah, I'll be sure to tell me clients that. Sometimes you don't have a choice -- you have to work with what they got. Cheers, tedd -- 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] Selecting all records between a date range
On Oct 2, 2008, at 1:31 PM, Robbert van Andel wrote: What is the actual code that you use to run the query. You've shown us how you set up the query but not more. Something like $result = mysql_query($query,$conn); Here is the code I use: $row[]= mysql_query($sql) or die(Could not perform query: . mysql_error()); $result = $row[0]; while ($row = mysql_fetch_assoc($result)){ $timein = date(m/d/y h:i:s, $row['timein']); $timeout = date(m/d/y h:i:s, $row['timeout']); $totalday = ($row['timeout'] - $row['timein']); $totalday = $totalday/60/60; $totalday = round($totalday, 2); $totalWeek += $totalday; // Builds the total from the daily total echo ADMIN tr td{$row['Name']}/td td{$timein}/td td{$timeout}/td td{$totalday}/td /tr ADMIN; } # Display Weekly total echo WEEKTOTAL tr td colspan='4' align='right'TOTAL FOR WEEK: {$totalWeek}/td /tr WEEKTOTAL; echo /table /div /body; Works out really well. Now I just need to show it to the boss, change every possible thing about it, until I hate it and they love it and call it good :) -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED]
Re: [PHP] Selecting all records between a date range
Jason Pruim wrote: On Oct 2, 2008, at 12:39 PM, Per Jessen wrote: Jason Pruim wrote: Hi Everyone, I am working on a app where I need to be able to select all the values from a database where the 'timein' field is between a certain date range... Essentially the last 7 days... SELECT * FROM timeStore WHERE timeinDATE_SUB(now(),INTERVAL 7 DAYS) Hmmm... To do that, I'd have to store the date/timestamps in a different format... I'll look into this more, but I think I'd have to rewrite the program to make that work. Thanks for the suggestion though! Ummm you could always add this... http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_unix-timestamp SELECT * FROMtimeStore WHERE timeinUNIX_TIMESTAMP(DATE_SUB(NOW(),INTERVAL 7 DAYS)) -- 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] Selecting all records between a date range
On Oct 2, 2008, at 1:45 PM, Robbert van Andel wrote: In the original message you were assigning the query to $SQLTEST, but in the code below you're using $sql. It was a clean up... I had a working query... $sql so in attempting to improve this I didn't want to lose the original sql so I developed in $SQLTEST which worked perfectly. Also, $sql is defined in a fairly extensive switch statement so I didn't want to get rid of all of that for testing :0 On Thu, Oct 2, 2008 at 10:40 AM, Jason Pruim [EMAIL PROTECTED] wrote: On Oct 2, 2008, at 1:31 PM, Robbert van Andel wrote: What is the actual code that you use to run the query. You've shown us how you set up the query but not more. Something like $result = mysql_query($query,$conn); Here is the code I use: $row[]= mysql_query($sql) or die(Could not perform query: . mysql_error()); $result = $row[0]; while ($row = mysql_fetch_assoc($result)){ $timein = date(m/d/y h:i:s, $row['timein']); $timeout = date(m/d/y h:i:s, $row['timeout']); $totalday = ($row['timeout'] - $row['timein']); $totalday = $totalday/60/60; $totalday = round($totalday, 2); $totalWeek += $totalday; // Builds the total from the daily total echo ADMIN tr td{$row['Name']}/td td{$timein}/td td{$timeout}/td td{$totalday}/td /tr ADMIN; } # Display Weekly total echo WEEKTOTAL tr td colspan='4' align='right'TOTAL FOR WEEK: {$totalWeek}/td /tr WEEKTOTAL; echo /table /div /body; Works out really well. Now I just need to show it to the boss, change every possible thing about it, until I hate it and they love it and call it good :) -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED]
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] Re: php server push
On Thu, Oct 2, 2008 at 6:53 AM, Nathan Rixham [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Hi, (i hope this is the right place to ask questions like below) I am trying to use content type 'multipart/x-mixed-replace' to achive server pushing and I have the following piece of code, which works perfectly. [snip] I hope I cound explain my problem clearly thank you in advance Christian Guttmann ahh an age old problem; in short you need something like meteor to handle this (a different http server); tbh the http protocol isn't cut out for this. You may want to save some time and look into XMPP with PUB-SUB; it's lightweight permanent client server connection with server push (ignite realtime/jive software do a great XMPP server that's opensource ;) Regards and sorry for the vagueness - there are tonnes of articles everywhere on the net documenting the problems; this is why everybody poll's all the time. if you do want a strictly PHP resolution then look into making your own multiprocess daemon with socket stream server / client and the stream_ functions - rather complicated and not a standard way fo doing things, but fun :) -- 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 http://sourceforge.net/projects/comet/ might be what you are looking for -- Bastien Cat, the other other white meat
[PHP] PHP job available, Phoenix, AZ, USA
I just saw this. If someone is in the Phoenix, AZ, USA area and wants a job writing/maintaining PHP code, this may be right for you. Contact details below: --- azcentral.com, Arizona's leading online source for up to date news and information, is seeking a Senior Online Developer to join our highly successful team! On a day to day basis, this individual will be responsible for providing Web-based technology solutions that support the objectives and mission of azcentral.com, a Gannett property. Participates in the creation and ongoing support of software applications, tools and technologies to enhance the development and growth of Digital Media services running in a Linux, Apache, MySQL, and PHP environment. Participates in cross-functional and/or cross-unit IT projects. Works in a team environment to ensure customer's needs are met. Works as the customer's primary contact for specific applications. Specific Requirements: To be qualified for this position the ideal candidate will have two years experience in online development or publishing, with an emphasis on coding, troubleshooting, and supporting a Linux Apache environment. Advanced or expert level Linux/Apache/MySQL/PHP. Must have experience in the development and support of a heavily trafficked, load balanced web environment, and basic HTML/CSS and web/interface design experience. Familiarity with commercial online services. Basic understanding of networking and systems infrastructure concepts. Strong communications and teamwork skills will be critical. Contact: jim.lindsey[AT]azcentral[DOT]com with a resume. - ...I don't really know any more than what's posted above, but will try to answer any questions if you send me an e-mail *off-list*. Hope this helps, -- For every complex problem, there is a solution that is simple, neat, and wrong. My blog: http://crow202.org/wordpress/ Matt G|There is no Darkness in Eternity/But only Light too dim for us to see -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php