Re: [PHP] Foreach and mydql_query problem

2013-07-23 Thread Karl-Arne Gjersøyen
Liam. > 3Sharp Ltd. > > T: 0845 6018370 > F: 0845 6018369 > > -Original Message- > From: Karl-Arne Gjersøyen [mailto:karlar...@gmail.com ] > Sent: 22 July 2013 12:39 > To: PHP Mailinglist > Subject: Re: [PHP] Foreach and mydql_query problem > > 2013/

Re: [PHP] Foreach and mydql_query problem

2013-07-22 Thread Jim Lucas
On 07/22/2013 04:39 AM, Karl-Arne Gjersøyen wrote: Might I suggest that you place your include for ../../tilkobling.php at the very top of this page? It would save you from possibly including it twice. // The acutual source code is below: // ==

Re: [PHP] Foreach and mydql_query problem

2013-07-22 Thread Jim Giner
Your original code snippet had some errors. It really couldn't have been what you wanted to do. Example: You have a named field of 'number_of_items' and then you try to retreive $_POST['number_of_itemsi']. That won't work. Then you have a var called $number_of_items which we don't see defi

Re: [PHP] Foreach and mydql_query problem

2013-07-22 Thread Stuart Dallas
On 22 Jul 2013, at 13:25, Karl-Arne Gjersøyen wrote: > 2013/7/22 Stuart Dallas > On 22 Jul 2013, at 12:56, Karl-Arne Gjersøyen wrote: > > > 2013/7/22 Stuart Dallas > > > >> > >> On 22 Jul 2013, at 08:04, Tamara Temple wrote: > >> > >>> On Jul 22, 2013, at 1:19 AM, Karl-Arne Gjersøyen > >> w

Re: [PHP] Foreach and mydql_query problem

2013-07-22 Thread Karl-Arne Gjersøyen
2013/7/22 Stuart Dallas > On 22 Jul 2013, at 12:56, Karl-Arne Gjersøyen wrote: > > > 2013/7/22 Stuart Dallas > > > >> > >> On 22 Jul 2013, at 08:04, Tamara Temple > wrote: > >> > >>> On Jul 22, 2013, at 1:19 AM, Karl-Arne Gjersøyen > >> wrote: > >>> > Hello again. > I have this this

Re: [PHP] Foreach and mydql_query problem

2013-07-22 Thread Stuart Dallas
On 22 Jul 2013, at 12:56, Karl-Arne Gjersøyen wrote: > 2013/7/22 Stuart Dallas > >> >> On 22 Jul 2013, at 08:04, Tamara Temple wrote: >> >>> On Jul 22, 2013, at 1:19 AM, Karl-Arne Gjersøyen >> wrote: >>> Hello again. I have this this source code that not work as I want... >

Re: [PHP] Foreach and mydql_query problem

2013-07-22 Thread Karl-Arne Gjersøyen
2013/7/22 Stuart Dallas > > On 22 Jul 2013, at 08:04, Tamara Temple wrote: > > > On Jul 22, 2013, at 1:19 AM, Karl-Arne Gjersøyen > wrote: > > > >> Hello again. > >> I have this this source code that not work as I want... > >> > >> THe PHP/HTHML form fields is generated by a while loop and look

Re: [PHP] Foreach and mydql_query problem

2013-07-22 Thread Karl-Arne Gjersøyen
2013/7/22 Tamara Temple > > On Jul 22, 2013, at 1:19 AM, Karl-Arne Gjersøyen > wrote: > > > Hello again. > > I have this this source code that not work as I want... > > > > THe PHP/HTHML form fields is generated by a while loop and looks like > this: > > > > " required="required"> > > > > > > th

Re: [PHP] Foreach and mydql_query problem

2013-07-22 Thread Stuart Dallas
On 22 Jul 2013, at 08:04, Tamara Temple wrote: > On Jul 22, 2013, at 1:19 AM, Karl-Arne Gjersøyen wrote: > >> Hello again. >> I have this this source code that not work as I want... >> >> THe PHP/HTHML form fields is generated by a while loop and looks like this: >> >> " required="required">

Re: [PHP] Foreach and mydql_query problem

2013-07-22 Thread Tamara Temple
On Jul 22, 2013, at 1:19 AM, Karl-Arne Gjersøyen wrote: > Hello again. > I have this this source code that not work as I want... > > THe PHP/HTHML form fields is generated by a while loop and looks like this: > > " required="required"> > > > the php source code look like this: > if(!empty($

Re: [PHP] foreach

2012-10-17 Thread tamouse mailing lists
On Wed, Oct 17, 2012 at 6:07 PM, Larry Garfield wrote: > Nothing is wrong with mysqli per se. It's up to date and secure, and > certainly better than ext/mysql. I recommend PDO over mysqli because: > > 1) PHP-engine-level global state (ie, not specifying a connection) is the > source of most (al

Re: [PHP] foreach

2012-10-17 Thread Larry Garfield
On 10/17/12 10:17 AM, Matijn Woudt wrote: On Wed, Oct 17, 2012 at 1:25 AM, Larry Garfield wrote: For the love of god, please stop using ext/mysql (aka the mysql_* functions). It's insecure and slow and lacks features. Instead, use PDO, and bind your parameters. As a nice bonus, the result f

Re: [PHP] foreach

2012-10-17 Thread Matijn Woudt
On Wed, Oct 17, 2012 at 1:25 AM, Larry Garfield wrote: > > For the love of god, please stop using ext/mysql (aka the mysql_* > functions). It's insecure and slow and lacks features. > > Instead, use PDO, and bind your parameters. As a nice bonus, the result > from a PDO-based query is not a raw

Re: [PHP] foreach

2012-10-16 Thread tamouse mailing lists
On Tue, Oct 16, 2012 at 6:25 PM, Larry Garfield wrote: > Instead, use PDO, and bind your parameters. As a nice bonus, the result > from a PDO-based query is not a raw resource but an iteratable object, which > means you can foreach() it. > > http://php.net/manual/en/book.pdo.php > > $conn = new P

Re: [PHP] foreach

2012-10-16 Thread Larry Garfield
On 10/15/12 9:05 PM, David McGlone wrote: On Monday, October 15, 2012 08:21:23 PM you wrote: Bastien Koert On 2012-10-15, at 8:16 PM, David McGlone wrote: I've been sitting here playing around with foreach() and I'm wondering why I am getting these results. here's what I've been fooling aroun

Re: [PHP] foreach

2012-10-16 Thread David McGlone
On Tuesday, October 16, 2012 09:46:26 AM you wrote: > > Here's what I ended up with after you gave me the advise: > > $result = mysql_query("SELECT * FROM items"); > > > > $rows = array(); > > while($row = mysql_fetch_array($result)) > > > >$rows[] = $row; > > > > foreach($rows as

Re: [PHP] foreach

2012-10-16 Thread Jim Giner
On 10/15/2012 8:39 PM, Jim Lucas wrote: On 10/15/2012 05:16 PM, David McGlone wrote: I've been sitting here playing around with foreach() and I'm wondering why I am getting these results. here's what I've been fooling around with. the code has no perticular meaning, but I noticed if the script f

RE: [PHP] foreach

2012-10-16 Thread Ashley Sheridan
On Tue, 2012-10-16 at 10:11 -0400, Steven Staples wrote: > > -Original Message- > > From: Matijn Woudt [mailto:tijn...@gmail.com] > > Steve, > > > > Please watch your language on this list. > > > > - Matijn > > > > My apologies, I guess using $foo == $bar would have been a better choic

RE: [PHP] foreach

2012-10-16 Thread Steven Staples
> -Original Message- > From: Matijn Woudt [mailto:tijn...@gmail.com] > Steve, > > Please watch your language on this list. > > - Matijn > My apologies, I guess using $foo == $bar would have been a better choice... I forget sometimes, I am used to chatting with my close friends, where s

Re: [PHP] foreach

2012-10-16 Thread Matijn Woudt
On Tue, Oct 16, 2012 at 3:46 PM, Steven Staples wrote: > One thing I do, is my coding and bracing style is something that Tedd > Sperling doesn't like (there have been many discussions about bracing > styles), I keep my braces all in line, and always use them in my if()s... > ie: > > And I do th

RE: [PHP] foreach

2012-10-16 Thread Steven Staples
> Here's what I ended up with after you gave me the advise: > $result = mysql_query("SELECT * FROM items"); > $rows = array(); > while($row = mysql_fetch_array($result)) >$rows[] = $row; > foreach($rows as $row){ > $product = $row['product']; > $price = $row['price']; > echo "$pro

Re: [PHP] foreach

2012-10-15 Thread David McGlone
On Monday, October 15, 2012 08:21:23 PM you wrote: > Bastien Koert > > On 2012-10-15, at 8:16 PM, David McGlone wrote: > > I've been sitting here playing around with foreach() and I'm wondering why > > I am getting these results. here's what I've been fooling around with. > > the code has no pert

Re: [PHP] foreach

2012-10-15 Thread Jim Lucas
On 10/15/2012 05:16 PM, David McGlone wrote: I've been sitting here playing around with foreach() and I'm wondering why I am getting these results. here's what I've been fooling around with. the code has no perticular meaning, but I noticed if the script fails, I get the sentence "Too expensive I

Re: [PHP] foreach

2012-10-15 Thread Bastien
Bastien Koert On 2012-10-15, at 8:16 PM, David McGlone wrote: > I've been sitting here playing around with foreach() and I'm wondering why I > am getting these results. here's what I've been fooling around with. the code > has no perticular meaning, but I noticed if the script fails, I get t

RE: [PHP] [foreach] - is it proper to...

2012-05-31 Thread Mackintosh, Mike
-Original Message- From: Tedd Sperling [mailto:t...@sperling.com] Sent: Thursday, May 31, 2012 1:01 PM To: php-general General Cc: Tristan Subject: Re: [PHP] [foreach] - is it proper to... On May 31, 2012, at 12:48 PM, Tristan wrote: > I'm using Zend Studio and it had a suggest

Re: [PHP] [foreach] - is it proper to...

2012-05-31 Thread Tedd Sperling
On May 31, 2012, at 12:48 PM, Tristan wrote: > I'm using Zend Studio and it had a suggestion that I do a foreach as such > > foreach($entry as $entry){ > > } > > instead of > > foreach($entries as $entry){ > > } > > they both seem to work but, from a readability standpoint and just makes > m

Re: [PHP] [foreach] - is it proper to...

2012-05-31 Thread Tristan
Thanks, well that's why I was asking because we just let a guy go for doing stuff like that among other obvious bad coding issues and terrible logic. The guy didn't know what he was doing but, I wanted to make sure I wasn't out of my mind by pointing that out. I am new to Zend Studio so I don't kno

Re: [PHP] [foreach] - is it proper to...

2012-05-31 Thread Daniel Brown
On Thu, May 31, 2012 at 12:48 PM, Tristan wrote: > I'm using Zend Studio and it had a suggestion that I do a foreach as such > > foreach($entry as $entry){ > > } which would be the same as `foreach ($entry)` --- a syntax option that doesn't exist, but would be ideal. > foreach($entries

Re: [PHP] foreach

2012-04-06 Thread tamouse mailing lists
On Thu, Apr 5, 2012 at 3:15 PM, Ethan Rosenberg wrote: > I know I am missing something fundamental - but I have no idea where to > start to look. It's really difficult to figure out what you're asking. Your code snippets and associated output seem all jumbled up. It would help greatly if they wer

RE: [PHP] foreach weirdness

2012-03-25 Thread Arno Kuhl
Note that somewhat similar error was discussed on this list a few months ago[1]. You could probably have solved it yourself if you searched the mailing list archives. - Matijn [1] http://www.mail-archive.com/php-general@lists.php.net/msg269552.html --- Thanks Matijn, I missed that discussion,

RE: [PHP] foreach weirdness

2012-03-25 Thread Arno Kuhl
Requesting that will at least require a major-release (f.e. PHP 6.0) ... but I would rather request to add a notice or warning to the documentation of references to remind stuff like that. http://www.php.net/manual/en/language.references.php I think this is stuff more people will stumble over ...

Re: [PHP] foreach weirdness

2012-03-25 Thread Simon Schick
2012/3/25 Arno Kuhl : > > will not only give the wrong result, it will corrupt the array for *any* > further use of that array. I still think it’s a bug according to the > definition of foreach in the php manual. Maybe php needs to do an implicit > unset at the closing brace of the foreach where

Re: [PHP] foreach weirdness

2012-03-25 Thread Matijn Woudt
On Sun, Mar 25, 2012 at 4:11 PM, Arno Kuhl wrote: > From: Simon Schick [mailto:simonsimc...@googlemail.com] > Sent: 24 March 2012 12:30 AM > To: Robert Cummings > Cc: a...@dotcontent.net; php-general@lists.php.net > Subject: Re: [PHP] foreach weirdness > > 2012/3/23 Robert

RE: [PHP] foreach weirdness

2012-03-25 Thread Arno Kuhl
From: Simon Schick [mailto:simonsimc...@googlemail.com] Sent: 24 March 2012 12:30 AM To: Robert Cummings Cc: a...@dotcontent.net; php-general@lists.php.net Subject: Re: [PHP] foreach weirdness 2012/3/23 Robert Cummings > > On 12-03-23 11:16 AM, Arno Kuhl wrote: >> >> &g

RE: [PHP] foreach weirdness

2012-03-25 Thread Arno Kuhl
> See this following example that illustrates the problem: > $array = array(0, 1, 2, 3, 4, 5, 6); > foreach ($array as $index=>$value) { > if ( ($index+1) < count($array) ) { > $array[$index+1] += $value; > } > echo $value." "; > } > echo ""; > foreach ($array as

Re: [PHP] foreach weirdness

2012-03-24 Thread Robert Cummings
On 12-03-24 11:15 AM, Al wrote: On 3/23/2012 10:11 PM, Robert Cummings wrote: On 12-03-23 06:30 PM, Simon Schick wrote: 2012/3/23 Robert Cummings On 12-03-23 11:16 AM, Arno Kuhl wrote: it still does not produce the correct result: 0 1 3 6 10 15 21 0 1 3 6 10 15 15 This looks like a bu

Re: [PHP] foreach weirdness

2012-03-24 Thread Al
On 3/23/2012 10:11 PM, Robert Cummings wrote: On 12-03-23 06:30 PM, Simon Schick wrote: 2012/3/23 Robert Cummings On 12-03-23 11:16 AM, Arno Kuhl wrote: it still does not produce the correct result: 0 1 3 6 10 15 21 0 1 3 6 10 15 15 This looks like a bug... the last row should be the s

Re: [PHP] foreach weirdness

2012-03-23 Thread Robert Cummings
On 12-03-23 06:30 PM, Simon Schick wrote: 2012/3/23 Robert Cummings On 12-03-23 11:16 AM, Arno Kuhl wrote: it still does not produce the correct result: 0 1 3 6 10 15 21 0 1 3 6 10 15 15 This looks like a bug... the last row should be the same. What version of PHP are you using? Have you

Re: [PHP] foreach weirdness

2012-03-23 Thread Simon Schick
2012/3/23 Robert Cummings > > On 12-03-23 11:16 AM, Arno Kuhl wrote: >> >> >> it still does not produce the correct result: >> 0 1 3 6 10 15 21 >> 0 1 3 6 10 15 15 > > > This looks like a bug... the last row should be the same. What version of > PHP are you using? Have you checked the online bug r

Re: [PHP] foreach weirdness

2012-03-23 Thread Robert Cummings
On 12-03-23 02:04 PM, Arno Kuhl wrote: Hi Rob I'm using php 5.3.5. What result do you get when you run this code? I haven't checked any bug reports, I'll google to see where I would do that. Your code gets round the problem, but I was specifically referring to the use of foreach with its unexp

RE: [PHP] foreach weirdness

2012-03-23 Thread Arno Kuhl
-Original Message- From: Robert Cummings [mailto:rob...@interjinn.com] Sent: 23 March 2012 06:11 PM To: a...@dotcontent.net Cc: php-general@lists.php.net Subject: Re: [PHP] foreach weirdness On 12-03-23 11:16 AM, Arno Kuhl wrote: > The following snippet is copied from the php man

Re: [PHP] foreach weirdness

2012-03-23 Thread Robert Cummings
On 12-03-23 11:16 AM, Arno Kuhl wrote: The following snippet is copied from the php manual: foreach ($arr as $key => $value) { echo "Key: $key; Value: $value\n"; } I've always used the foreach loop that way. But recently I started hitting some really odd problems. See this following ex

RE: [PHP] Foreach question

2011-07-06 Thread Dajka Tamás
.com] Sent: Tuesday, July 05, 2011 5:47 PM To: Robert Cummings Cc: Dajka Tamás; php-general@lists.php.net Subject: Re: [PHP] Foreach question Just use count($arr) in your for-header, as it get's executed again for each loop. 1), array('id'=>2))

Re: [PHP] Foreach question

2011-07-05 Thread Robert Cummings
On 11-07-05 11:46 AM, Louis Huppenbauer wrote: Just use count($arr) in your for-header, as it get's executed again for each loop. 1), array('id'=>2)); for($i=0;$i $arr[$i]['id']+1); } } ?> Ok, so the extents are being updated on each pass of the loop :) Ch

Re: [PHP] Foreach question

2011-07-05 Thread Louis Huppenbauer
Just use count($arr) in your for-header, as it get's executed again for each loop. 1), array('id'=>2)); for($i=0;$i $arr[$i]['id']+1); } } ?> 2011/7/5 Robert Cummings : > On 11-07-05 10:48 AM, Dajka Tamás wrote: >> >> Thanks, that was interesting :) I think I got o

Re: [PHP] Foreach question

2011-07-05 Thread Stuart Dallas
On Tue, Jul 5, 2011 at 2:40 PM, Dajka Tamas wrote: > I've bumped into an interesting thing with foreach. I really don't know, if > this is normal working, or why it is, so I got curious. > > The script: > > foreach ( $cats as &$c ) { > echo $c['id']; > if ( $c['id'] <

Re: [PHP] Foreach question

2011-07-05 Thread Robert Cummings
On 11-07-05 10:48 AM, Dajka Tamás wrote: Thanks, that was interesting :) I think I got one step further in understanding PHP :) BTW, I've changed the loop to 'for' and it's working well :) Can you show us your for loop? I'm not immediately sure how you use a for loop to traverse a growing nu

Re: [PHP] Foreach question

2011-07-05 Thread Robert Cummings
On 11-07-05 09:40 AM, Dajka Tamas wrote: foreach ( $cats as&$c ) { echo $c['id']; if ( $c['id']< 5 ) { $c['id']++; $cats[] = $c; } } Given that you seem to want the above functi

RE: [PHP] Foreach question

2011-07-05 Thread Dajka Tamás
Dajka Tamás Cc: php-general@lists.php.net Subject: Re: [PHP] Foreach question On 11-07-05 10:39 AM, Dajka Tamás wrote: > Ok, but if it would be that way I shouldn't get '122334455' for second > output, no? The item count increments with every iteration of the loop. > > Or yo

Re: [PHP] Foreach question

2011-07-05 Thread Robert Cummings
On 11-07-05 10:39 AM, Dajka Tamás wrote: Ok, but if it would be that way I shouldn't get '122334455' for second output, no? The item count increments with every iteration of the loop. Or you're saying that, it checks for an existance of nextitem before every loop, and that will fail with just

Re: [PHP] Foreach question

2011-07-05 Thread Robert Cummings
On 11-07-05 10:39 AM, Dajka Tamás wrote: Ok, but if it would be that way I shouldn't get '122334455' for second output, no? The item count increments with every iteration of the loop. Or you're saying that, it checks for an existance of nextitem before every loop, and that will fail with jus

RE: [PHP] Foreach question

2011-07-05 Thread Dajka Tamás
l always return true with two elements? ( since the first elements copy is pushed as third element, etc ) -Original Message- From: Robert Cummings [mailto:rob...@interjinn.com] Sent: Tuesday, July 05, 2011 4:28 PM To: Dajka Tamás Cc: php-general@lists.php.net Subject: Re: [PHP] Foreach q

Re: [PHP] Foreach question

2011-07-05 Thread Louis Huppenbauer
I don't think that it does this: if ( count($elements) == 1 ) then loop 1; else loop normally; It's probably more something like that: $i=count($elements); loop: $i--; if($i == 0) $last_loop = true; else $last_loop = false if($last_loop) exit; else goto loop; But aside from tha

Re: [PHP] Foreach question

2011-07-05 Thread Robert Cummings
On 11-07-05 10:20 AM, Dajka Tamás wrote: Hi, Yeah, I'm really want to do that, since I'm working with the elements of the original array ( skipped that part in sample code ). I've tried your suggestion, but it gives the same result, so on just one input is just gives back '1'. Ahhh... you w

RE: [PHP] Foreach question

2011-07-05 Thread Dajka Tamás
= $c; } } But this is 'while' and it pops all elements from the array... Cheers, Tamas -Original Message- From: Louis Huppenbauer [mailto:louis.huppenba...@gmail.com] Sent: Tuesday, July 05, 2011 4:12 PM To: Robert Cummings Cc: Dajka Tamas; php-general@lists.p

RE: [PHP] Foreach question

2011-07-05 Thread Dajka Tamás
e same with each case ) Cheers, Tamas -Original Message- From: Robert Cummings [mailto:rob...@interjinn.com] Sent: Tuesday, July 05, 2011 4:06 PM To: Dajka Tamas Cc: php-general@lists.php.net Subject: Re: [PHP] Foreach question On 11-07-05 09:40 AM, Dajka Tamas wrote: > Hi a

Re: [PHP] Foreach question

2011-07-05 Thread Louis Huppenbauer
Or maybe he tried to do the following? ($c['id'] + 1)); } } ?> 2011/7/5 Robert Cummings : > > On 11-07-05 09:40 AM, Dajka Tamas wrote: >> >> Hi all, >> >> >> >> I've bumped into an interesting thing with foreach. I really don't know, >> if >> this is normal working, or why it is,

Re: [PHP] Foreach question

2011-07-05 Thread Robert Cummings
On 11-07-05 09:40 AM, Dajka Tamas wrote: Hi all, I've bumped into an interesting thing with foreach. I really don't know, if this is normal working, or why it is, so I got curious. The script: foreach ( $cats as&$c ) { echo $c['id']; if ( $c['id']< 5 )

Re: [PHP] Foreach question

2011-07-05 Thread Louis Huppenbauer
Hi there I think that foreach in your first example just knowns that this should be the last loop (as the array only contains 1 element at start) and so stops there. In your 2nd example however the first loop isn't the last, so the array get's checked again, and now there's another element, so...

Re: [PHP] foreach insert error

2009-10-07 Thread Paul M Foster
On Wed, Oct 07, 2009 at 03:31:14PM -0700, Haig Davis wrote: > Hello All, > > I have spent the entire day trying to get my calendar app to function > correctly --- I have no problem with the actual functioning of the > calendar. What is giving me trouble is for each calendar day the user has > th

Re: [PHP] foreach insert error

2009-10-07 Thread Jim Lucas
Haig Davis wrote: > Hello All, > > I have spent the entire day trying to get my calendar app to function > correctly --- I have no problem with the actual functioning of the > calendar. What is giving me trouble is for each calendar day the user has > the option to check a checkbox requesting the

Re: [PHP] ForEach Range Problems

2009-07-31 Thread Andrew Ballard
On Fri, Jul 31, 2009 at 4:51 PM, Miller, Terion wrote: > //Show all restaurants that start with $letter not > between "A" and "Z" > > $other = ctype_digit($letter); > > foreach(range('0','9') as $other) { > > $sql = "SELECT DISTINCT ID, name, address > FROMrestaurants >

Re: [PHP] ForEach Range Problems

2009-07-31 Thread Miller, Terion
-snip--- So I'm almost almost there, but now when I click the # it shows me all records, is my foreach range not right? //Create array with letters AND number sign $letters = range('A','Z');array_push($letters, '#');

Re: [PHP] ForEach Range Problems

2009-07-31 Thread Miller, Terion
On 7/31/09 3:08 PM, "Bastien Koert" wrote: On Fri, Jul 31, 2009 at 3:10 PM, Miller, Terion wrote: > > > > On 7/31/09 2:00 PM, "Miller, Terion" wrote: > > > > > On 7/31/09 1:56 PM, "Bastien Koert" wrote: > > $letters = ''; > > Nope still gives the same error: Notice: Undefined index: letter

Re: [PHP] ForEach Range Problems

2009-07-31 Thread Bastien Koert
On Fri, Jul 31, 2009 at 3:10 PM, Miller, Terion wrote: > > > > On 7/31/09 2:00 PM, "Miller, Terion" wrote: > > > > > On 7/31/09 1:56 PM, "Bastien Koert" wrote: > > $letters = ''; > > Nope still gives the same error:  Notice: Undefined index: letter > > Well getting closer with this but now my out

Re: [PHP] ForEach Range Problems

2009-07-31 Thread Miller, Terion
On 7/31/09 2:00 PM, "Miller, Terion" wrote: On 7/31/09 1:56 PM, "Bastien Koert" wrote: $letters = ''; Nope still gives the same error: Notice: Undefined index: letter Well getting closer with this but now my output menu is not a clickable link?

Re: [PHP] ForEach Range Problems

2009-07-31 Thread Miller, Terion
On 7/31/09 1:56 PM, "Bastien Koert" wrote: $letters = ''; Nope still gives the same error: Notice: Undefined index: letter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] ForEach Range Problems

2009-07-31 Thread Bastien Koert
On Fri, Jul 31, 2009 at 2:51 PM, Miller, Terion wrote: > > > > --snip--- > > -- > Well I almost have it with this, I keep getting an undefined index $letter > error though and then it outputs the $menu how do I fix that > >  //Create array with letters AND number sign                           > $

Re: [PHP] ForEach Range Problems

2009-07-31 Thread Miller, Terion
--snip--- -- Well I almost have it with this, I keep getting an undefined index $letter error though and then it outputs the $menu how do I fix that //Create array with letters AND number sign $letters = range('A','Z'); array_push($letters,

Re: [PHP] ForEach Range Problems

2009-07-31 Thread Shawn McKenzie
Miller, Terion wrote: > > > On 7/31/09 12:43 PM, "Bastien Koert" wrote: > > On Fri, Jul 31, 2009 at 1:40 PM, Miller, > Terion wrote: >> >> >> On 7/31/09 12:27 PM, "Bastien Koert" wrote: >> >> $letter = isset($_GET['letter']) ? $_GET['letter'] :""; >> >> echo ''; >> >> foreach(range('A','Z')

Re: [PHP] ForEach Range Problems

2009-07-31 Thread Miller, Terion
On 7/31/09 12:43 PM, "Bastien Koert" wrote: On Fri, Jul 31, 2009 at 1:40 PM, Miller, Terion wrote: > > > > On 7/31/09 12:27 PM, "Bastien Koert" wrote: > > $letter = isset($_GET['letter']) ? $_GET['letter'] :""; > > echo ''; > > foreach(range('A','Z') as $c){ > ($letter == $c) ? printf('%s

Re: [PHP] ForEach Range Problems

2009-07-31 Thread Bastien Koert
On Fri, Jul 31, 2009 at 1:40 PM, Miller, Terion wrote: > > > > On 7/31/09 12:27 PM, "Bastien Koert" wrote: > > $letter = isset($_GET['letter']) ? $_GET['letter'] :""; > >  echo ''; > >  foreach(range('A','Z') as $c){ >   ($letter == $c) ? printf('%s ',$c) : printf(' href="browse.php?letter=%s">%s 

Re: [PHP] ForEach Range Problems

2009-07-31 Thread Miller, Terion
On 7/31/09 12:27 PM, "Bastien Koert" wrote: $letter = isset($_GET['letter']) ? $_GET['letter'] :""; echo ''; foreach(range('A','Z') as $c){ ($letter == $c) ? printf('%s ',$c) : printf('%s ',$c,$c); } echo ''; //Other $bNumberShown = false; foreach(range('0','9') as $n){ if($le

Re: [PHP] ForEach Range Problems

2009-07-31 Thread Bastien Koert
On Fri, Jul 31, 2009 at 12:53 PM, Miller, Terion wrote: > > > > > I have this script that works, just a couple tweeks needed... > > 1. I don't want it to default to A being selected > 2. I need the number range part to only display one # sign not 10 of them, > somehow I have to have it pull any rec

Re: [PHP] foreach and form submission.

2009-03-30 Thread Jan G.B.
That would be correct. but two things I have to add: * it's called bad style to re-write (override) predefined vars like _POST, _GET, _SERVER ... * using strip_tags() to clean user-input for safe output ist not O.K.! use htmlspecialchars(), at least. Regards, 2009/3/28 Virgilio Quilario : >> Hi

Re: [PHP] foreach and form submission.

2009-03-30 Thread Igor Escobar
Try this... $_POST = array_map('stri_tags', $_POST); Igor Escobar systems analyst & interface designer www . igorescobar . com On Sat, Mar 28, 2009 at 6:21 PM, Angus Mann wrote: > Thanks Ashley...that did the trick. > After reading about the limitations of strip_tags I decided to just repla

Re: [PHP] foreach and form submission.

2009-03-28 Thread Angus Mann
Thanks Ashley...that did the trick. After reading about the limitations of strip_tags I decided to just replace the bad bits as below... It still uses your "foreach" suggestion but replaces "<" and ">" with "(" and ")" instead of stripping tags. I think I will extend the good and bad arrays to

Re: [PHP] foreach and form submission.

2009-03-28 Thread Virgilio Quilario
> Hi all. > > I'm writing a script that accepts several different forms with different > content. Depending on what data is sent with the form the script will do one > or the other think. > > Before the form data is processed I'd like to scrub it of HTML tags. > > I can do this manually as below

Re: [PHP] foreach and form submission.

2009-03-28 Thread Ashley Sheridan
On Sat, 2009-03-28 at 18:28 +1000, Angus Mann wrote: > Hi all. > > I'm writing a script that accepts several different forms with different > content. Depending on what data is sent with the form the script will do one > or the other think. > > Before the form data is processed I'd like to scru

Re: [PHP] foreach and destroying variables for memory saving

2008-12-10 Thread ceo
PHP does have garbage_collection, and it's crucial in long-running CLI scripts. Per is right, though, in that if your web-page Apache PHP script needs GC, you are doing something terribly wrong. It is not as aggressive/thorough as, say, the Lisp GC, but it's there. ymmv -- PHP Genera

Re: [PHP] foreach and destroying variables for memory saving

2008-12-10 Thread Per Jessen
Tim | iHostNZ wrote: > Somewhere i also read that one can save a lot of memory by destroying > variables. Is that done with unset, setting it to null or something > similar? unset() > So, i take there is no garbage collection in php? I've never > actually looked at the c source code of php. Ma

Re: [PHP] foreach question

2008-07-29 Thread Jason Pruim
On Jul 29, 2008, at 3:33 PM, Daniel Brown wrote: On Tue, Jul 29, 2008 at 3:25 PM, Jason Pruim <[EMAIL PROTECTED]> wrote: function random($random){ $randomQuery = "SELECT * FROM `current` ORDER BY Rand() LIMIT 2"; $result = mysql_query($randomQuery); $row[] = $result; forea

Re: [PHP] foreach question

2008-07-29 Thread Micah Gersten
You cannot do this: $row[] = $result; You need to loop around this: $row = mysql_fetch_assoc($result); Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Jason Pruim wrote: > Hey Everyone... > > So I am attempting to pull 2 random records from a MySQL databa

Re: [PHP] foreach question

2008-07-29 Thread Daniel Brown
On Tue, Jul 29, 2008 at 3:25 PM, Jason Pruim <[EMAIL PROTECTED]> wrote: > > function random($random){ > >$randomQuery = "SELECT * FROM `current` ORDER BY Rand() LIMIT 2"; > >$result = mysql_query($randomQuery); > $row[] = $result; > > > foreach($row as $key => $value) { > $random[$k

Re: [PHP] foreach loop to set variables

2008-04-25 Thread Jim Lucas
jamest wrote: I am passing an array to a class which I want to take the array data and create some variables from the array's keys and values. So I want to create (in this case 21) new variables that I want to create in the foreach but with no success. foreach ($formdata as $key => $value) {

Re: [PHP] foreach loop to set variables

2008-04-25 Thread jamest
Thats perfect. I didn't even know about this. Stut wrote: > > > $$key = $value; > > They're called variable variables - search the manual for that term > for more info. > > -Stut > > -- > http://stut.net/ > > -- View this message in context: http://www.nabble.com/foreach-loop-to-set

Re: [PHP] foreach loop to set variables

2008-04-25 Thread Casey
On Apr 25, 2008, at 6:12 AM, jamest <[EMAIL PROTECTED]> wrote: I am passing an array to a class which I want to take the array data and create some variables from the array's keys and values. So I want to create (in this case 21) new variables that I want to create in the foreach but wit

Re: [PHP] foreach loop to set variables

2008-04-25 Thread Jason Norwood-Young
On Fri, 2008-04-25 at 06:12 -0700, jamest wrote: > I am passing an array to a class which I want to take the array data and > create some variables from the array's keys and values. > > So I want to create (in this case 21) new variables that I want to create in > the foreach but with no success.

Re: [PHP] foreach loop to set variables

2008-04-25 Thread Stut
On 25 Apr 2008, at 14:12, jamest wrote: I am passing an array to a class which I want to take the array data and create some variables from the array's keys and values. So I want to create (in this case 21) new variables that I want to create in the foreach but with no success. foreach ($f

Re: [PHP] Foreach

2008-01-27 Thread Nathan Nobbe
On Jan 27, 2008 7:24 PM, Eric Butera <[EMAIL PROTECTED]> wrote: > I was just pointing out how fragmented PHP5+ is. Look at the docs on > SPL and the DOM stuff, it's horrible. > i hear you, and i agree, most of the php docs are good, but some of the oop stuff is kinda weak, like SoapClient, and D

Re: [PHP] Foreach

2008-01-27 Thread Eric Butera
On Jan 27, 2008 1:33 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote: > On Jan 23, 2008 8:02 AM, Eric Butera <[EMAIL PROTECTED]> wrote: > > > Maybe someday SPL will become part of the PHP manual too. ;) > > > > ill admit, the doxygen documentation is a little daunting at first. at > least > more so tha

Re: [PHP] Foreach

2008-01-27 Thread Nathan Nobbe
On Jan 23, 2008 8:02 AM, Eric Butera <[EMAIL PROTECTED]> wrote: > Maybe someday SPL will become part of the PHP manual too. ;) > ill admit, the doxygen documentation is a little daunting at first. at least more so than phpDocumentor for example. but once youve cruised around the spl docs for a

Re: [PHP] Foreach

2008-01-23 Thread Eric Butera
On Jan 23, 2008 12:58 AM, Nathan Nobbe <[EMAIL PROTECTED]> wrote: > On Jan 18, 2008 5:24 PM, Richard Lynch <[EMAIL PROTECTED]> wrote: > > > If you are trying to keep the names and orders in "parallel" you need > > to do something not unlike: > > > > while (list($key, $name) = each($names)){ > > $o

Re: [PHP] Foreach

2008-01-22 Thread Nathan Nobbe
On Jan 18, 2008 5:24 PM, Richard Lynch <[EMAIL PROTECTED]> wrote: > If you are trying to keep the names and orders in "parallel" you need > to do something not unlike: > > while (list($key, $name) = each($names)){ > $order = $orders[$key]; > $query = "update whatever set order = $order where nam

Re: [PHP] Foreach

2008-01-18 Thread mike
On 1/18/08, Andrés Robinet <[EMAIL PROTECTED]> wrote: > Please, don't get me wrong, I'm just curious, how does the server know when > the browser is closed? Do you use javascript (AJAX) or something to notify > the server? it's a browser thing, not a server thing. the browser will "forget" the ses

RE: [PHP] Foreach

2008-01-18 Thread Andrés Robinet
> -Original Message- > From: Eric Butera [mailto:[EMAIL PROTECTED] > Sent: Friday, January 18, 2008 11:21 PM > To: mike > Cc: PHP eMail List > Subject: Re: [PHP] Foreach > > On Jan 18, 2008 5:06 PM, mike <[EMAIL PROTECTED]> wrote: > > On 1/18/08, E

Re: [PHP] Foreach

2008-01-18 Thread Eric Butera
On Jan 18, 2008 5:06 PM, mike <[EMAIL PROTECTED]> wrote: > On 1/18/08, Eric Butera <[EMAIL PROTECTED]> wrote: > > > Nonetheless as I keep re-iterating, people will copy and paste this > > stuff as is because they don't know better. It is the responsibility > > of people writing the answers to make

Re: [PHP] Foreach

2008-01-18 Thread mike
On 1/18/08, Eric Butera <[EMAIL PROTECTED]> wrote: > Nonetheless as I keep re-iterating, people will copy and paste this > stuff as is because they don't know better. It is the responsibility > of people writing the answers to make sure their code is validated and > as "secure" as possible unless

Re: [PHP] Foreach

2008-01-18 Thread Richard Lynch
If you are trying to keep the names and orders in "parallel" you need to do something not unlike: while (list($key, $name) = each($names)){ $order = $orders[$key]; $query = "update whatever set order = $order where name = '$name'"; } This completely ignores security and error checking in the

Re: [PHP] Foreach

2008-01-18 Thread Eric Butera
On Jan 18, 2008 2:55 PM, Pastor Steve <[EMAIL PROTECTED]> wrote: > > Here is the output, thanks! > > Array ( [page_name] => [image] => spacer.gif [text_head] => [name] => Array > ( [0] => Holiday Inn [1] => The Rib Room [2] => Winner ) [order] => Array ( > [0] => 3 [1] => 3 [2] => 3 ) [add-page]

  1   2   3   >