RE: [PHP] Validation problem with array.

2004-10-21 Thread Stuart Felenstein
See below:
--- Graham Cossey [EMAIL PROTECTED] wrote:

 Also, this line :
 foreach($_SESSION['skills'] as $key = $skill)
 could read
 foreach($skills as $key = $skill)
 as you have the line:
 $skills = $_SESSION['skills'];
 Same for skys and slus.
 Graham

Graham, 
I've read this over and over and I must be dense
because Im not totally comprehending it.

Let me show you how I set it all up. Remember it's  a
multi page form:
So the form elements are: skills[], skys[], slus[]
Then on the next page I have to still pass the session
variables, and so:

$_SESSION['skills'] = $_POST['skill']; 
$_SESSION['skys'] = $_POST['sky']; 
$_SESSION['slus'] = $_POST['slu']; 

Now the transcation script:

$skills = $_SESSION['skills'];
$skys = $_SESSION['skys'];
$slus = $_SESSION['slus'];

foreach($_SESSION['skills'] as $key = $skill)
{
$query = INSERT INTO LurkProfiles_Skicerts
(SkicertID, ProfileID, SkilCerts, NumYear, Lused) 
VALUES (null, $LID, '$skill',
{$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]});
//$result = mysql_query($query);
$res6 = run_query($query);
echo $query;
}

I understand that in the insert statement I need not
repeat $_SESSION.
The rest though is fuzzy. 
It was working, now I'm getting some really odd
behaviour, in that, unless i fill in every field in
the form, I get a mysql syntax error.

Stuart

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Validation problem with array.

2004-10-21 Thread Andre Dubuc
Hi Stuart,

I haven't followed your thread too closely, but I did see something that might 
be the cause of your problems:

[snip]

 Let me show you how I set it all up. Remember it's  a
 multi page form:
 So the form elements are: skills[], skys[], slus[]
 Then on the next page I have to still pass the session
 variables, and so:

 $_SESSION['skills'] = $_POST['skill'];
 $_SESSION['skys'] = $_POST['sky'];
 $_SESSION['slus'] = $_POST['slu'];

 Now the transcation script:

 $skills = $_SESSION['skills'];
 $skys = $_SESSION['skys'];
 $slus = $_SESSION['slus'];

 foreach($_SESSION['skills'] as $key = $skill)
^^  ^^  

[snip]

It's my understanding that where I've put  ^^  should be enclosed by braces, 
otherwise you'll get some starnge behaviour. 

I'm puzzled why you reverted to $_SESSION['skills'] when the line above you've 
set $skills = $_SESSION['skills']??

HTH,
Andre

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Validation problem with array.

2004-10-21 Thread Stuart Felenstein
You mean why do i have $_SESSION['skills'] in the
foreach ?

Stuart
--- Andre Dubuc [EMAIL PROTECTED] wrote:

 Hi Stuart,
 
 I haven't followed your thread too closely, but I
 did see something that might 
 be the cause of your problems:
 
 [snip]
 
  Let me show you how I set it all up. Remember it's
  a
  multi page form:
  So the form elements are: skills[], skys[], slus[]
  Then on the next page I have to still pass the
 session
  variables, and so:
 
  $_SESSION['skills'] = $_POST['skill'];
  $_SESSION['skys'] = $_POST['sky'];
  $_SESSION['slus'] = $_POST['slu'];
 
  Now the transcation script:
 
  $skills = $_SESSION['skills'];
  $skys = $_SESSION['skys'];
  $slus = $_SESSION['slus'];
 
  foreach($_SESSION['skills'] as $key = $skill)
   ^^  ^^  
 

 I'm puzzled why you reverted to $_SESSION['skills']
 when the line above you've 
 set $skills = $_SESSION['skills']??
 
 HTH,
 Andre
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Validation problem with array.

2004-10-21 Thread Graham Cossey
See inline:

[snip]
 
 Now the transcation script:
 
 $skills = $_SESSION['skills'];
 $skys = $_SESSION['skys'];
 $slus = $_SESSION['slus'];
 
 foreach($_SESSION['skills'] as $key = $skill)
  ^^^
 ($skills as $key = $skill)
 {
if ($skill != '') // Has this skill been entered?
{
  // You may also want to check for sky  slu entries

 $query = INSERT INTO LurkProfiles_Skicerts
 (SkicertID, ProfileID, SkilCerts, NumYear, Lused) 
 VALUES (null, $LID, '$skill',
 {$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]});
   ^^^   ^^^
   $skys[$key]   $slus[$key]

 //$result = mysql_query($query);
 $res6 = run_query($query);
 echo $query;
  ^^^
  What does this output?

}// end if ($skill != '')

 }
 
 I understand that in the insert statement I need not
 repeat $_SESSION.
 The rest though is fuzzy. 
 It was working, now I'm getting some really odd
 behaviour, in that, unless i fill in every field in
 the form, I get a mysql syntax error.


HTH 
Graham

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Validation problem with array.

2004-10-21 Thread Stuart Felenstein
Graham, I'm going to make those changes.  Not sure if
that was creating some crazy behaviour. See inline:

--- Graham Cossey [EMAIL PROTECTED] wrote:


  {
 if ($skill != '') // Has this skill been
 entered?

I don't know if I care if it's been entered.  My main
concern would be to make sure that if a $skill was
entered, then a matching $skys and $slus
should be:
skills[0]-baker skys[0]-7 slus[0]-2002

but wouldn't want
skill[0]-baker skys[1]-7 slus[2]-2002

In other words I need to figure out how to check that
each line is complete.  But~ right now, it is
matching all the values/inputs correctly.  If someone
just chose a slus, seems the database won't take it.

 {
   // You may also want to check for sky  slu
 entries

Not sure why I would want too:

  //$result = mysql_query($query);
  $res6 = run_query($query);
  echo $query;
   ^^^
   What does this output?

It outputs the insert and values string.  
And it seems to print the iteration:

INSERT INTO LurkProfiles_Skicerts (SkicertID,
ProfileID, SkilCerts, NumYear, Lused) VALUES (null,
39, 'a', 2,1)INSERT INTO LurkProfiles_Skicerts
(SkicertID, ProfileID, SkilCerts, NumYear, Lused)
VALUES (null, 39, 'b', 3,2)INSERT INTO
LurkProfiles_Skicerts (SkicertID, ProfileID,
SkilCerts, NumYear, Lused) VALUES (null, 39, 'c',
4,3)INSERT INTO LurkProfiles_Skicerts (SkicertID,
ProfileID, SkilCerts, NumYear, Lused) VALUES (null,
39, 'd', 5,4)INSERT INTO LurkProfiles_Skicerts
(SkicertID, ProfileID, SkilCerts, NumYear, Lused)
VALUES (null, 39, 'e', 6,5)your insertions were
successful

 }// end if ($skill != '')

This probably makes sense to add , perhaps that is why
if I don't use all the elements for input I get a
syntax error.

Stuart

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Validation problem with array.

2004-10-21 Thread Graham Cossey
See inline:

[snip]
 
   {
  if ($skill != '') // Has this skill been
  entered?

 I don't know if I care if it's been entered.  My main
 concern would be to make sure that if a $skill was
 entered, then a matching $skys and $slus
 should be:
 skills[0]-baker skys[0]-7 slus[0]-2002

 but wouldn't want
 skill[0]-baker skys[1]-7 slus[2]-2002


So, you want to avoid all of the following:
  skill[0] 'baker'  skys[0] '7'  slus[0] ''
  skill[1] 'baker'  skys[1] ''   slus[1] '2002'
  skill[2] ''   skys[2] '7'  slus[2] '2002'
  skill[3] ''   skys[3] ''   slus[3] ''

You'll need to amend the if within the foreach loop to check for these.

if ($skill != ''  $skys[$key] != ''  $slus[$key] != '')

 In other words I need to figure out how to check that
 each line is complete.  But~ right now, it is
 matching all the values/inputs correctly.  If someone
 just chose a slus, seems the database won't take it.

But is this due to the sql statement being rejected as opposed to being
caught by your validation?


  {
// You may also want to check for sky  slu
  entries

 Not sure why I would want too:

You would want to because of the paragraph above about My main concern...


   //$result = mysql_query($query);
   $res6 = run_query($query);
   echo $query;
^^^
What does this output?

 It outputs the insert and values string.
 And it seems to print the iteration:

 INSERT INTO LurkProfiles_Skicerts (SkicertID,
 ProfileID, SkilCerts, NumYear, Lused) VALUES (null,
 39, 'a', 2,1)INSERT INTO LurkProfiles_Skicerts
 (SkicertID, ProfileID, SkilCerts, NumYear, Lused)
 VALUES (null, 39, 'b', 3,2)INSERT INTO
 LurkProfiles_Skicerts (SkicertID, ProfileID,
 SkilCerts, NumYear, Lused) VALUES (null, 39, 'c',
 4,3)INSERT INTO LurkProfiles_Skicerts (SkicertID,
 ProfileID, SkilCerts, NumYear, Lused) VALUES (null,
 39, 'd', 5,4)INSERT INTO LurkProfiles_Skicerts
 (SkicertID, ProfileID, SkilCerts, NumYear, Lused)
 VALUES (null, 39, 'e', 6,5)your insertions were
 successful

This is OK, it's just a formatting thing, try changing your echo to:

echo Query $key = $query br;

This should give you:

Query 0 = INSERT INTO LurkProfiles_Skicerts (SkicertID,ProfileID, SkilCerts,
NumYear, Lused) VALUES (null,39, 'a', 2,1)
Query 1 = INSERT INTO LurkProfiles_Skicerts (SkicertID, ProfileID,
SkilCerts, NumYear, Lused) VALUES (null,9, 'b', 3,2)
Query 2 = INSERT INTO LurkProfiles_Skicerts (SkicertID, ProfileID,
SkilCerts, NumYear, Lused) VALUES (null, 9, 'c', 4,3)
Query 3 = INSERT INTO LurkProfiles_Skicerts (SkicertID, ProfileID,
SkilCerts, NumYear, Lused) VALUES (null,39, 'd', 5,4)
Query 4 = INSERT INTO LurkProfiles_Skicerts (SkicertID, ProfileID,
SkilCerts, NumYear, Lused) VALUES (null, 9, 'e', 6,5)


  }// end if ($skill != '')

 This probably makes sense to add , perhaps that is why
 if I don't use all the elements for input I get a
 syntax error.

Possibly...

Graham

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Validation problem with array.

2004-10-21 Thread Stuart Felenstein
See inline:
--- Graham Cossey [EMAIL PROTECTED] wrote:

  In other words I need to figure out how to check
  that each line is complete. right now, it is
  matching all the values/inputs correctly.  If
  someone just chose a slus, seems the database

 But is this due to the sql statement being rejected
 as opposed to being
 caught by your validation?

What validation :) .  I haven't added that in yet,due
to figuring out why the insertions weren't taking.

   {
   // You may also want to check for sky 
   slu entries
   You would want to because of the paragraph above
   about My main concern...

Right now I have this [right below]: If I want to
check for skys and slus, I add another set of braces
with if($sky != '' ...
and below end if ($sky != '')


 foreach($skills as $key = $skill)
{
if ($skill != ''  $skys[$key] != '' 
$slus[$key] != '')
{
  
$query = INSERT INTO LurkProfiles_Skicerts
(SkicertID, ProfileID, SkilCerts, NumYear, Lused) 
VALUES (null, $LID, '$skill',
$skys[$key],$slus[$key]);
$res6 = run_query($query);
echo Query $key = $query br;
} end if ($skill != '')

}
Stuart

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Validation problem with array.

2004-10-21 Thread Graham Cossey

[snip]
 Right now I have this [right below]: If I want to
 check for skys and slus, I add another set of braces
 with if($sky != '' ...
 and below end if ($sky != '')
 
 
  foreach($skills as $key = $skill)
 {
 if ($skill != ''  $skys[$key] != '' 
 $slus[$key] != '')
 {
   
 $query = INSERT INTO LurkProfiles_Skicerts
 (SkicertID, ProfileID, SkilCerts, NumYear, Lused) 
 VALUES (null, $LID, '$skill',
 $skys[$key],$slus[$key]);
 $res6 = run_query($query);
 echo Query $key = $query br;
   } end if ($skill != '')
 
 }

That looks pretty much like what you want except for:

} //end if ($skill != '')
^^
Comment, this is just to help identify what the brace is closing.

Graham

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Validation problem with array.

2004-10-21 Thread Brent Baisley
Since your data on the client is linked, you should keep it linked on 
submission by nesting an array with in the array.
Your client HTML should like something like this:
input type=text name=skills[0][skill] value= size=20

select name=skills[0][skys] size=1
option ...
/select
select name=skills[0][Lused] size=1
option ...
/select
...
input type=text name=skills[1][skill] value= size=20
select name=skills[1][skys] size=1
option ...
/select
select name=skills[1][Lused] size=1
option ...
/select
All the way up to skills[10][...], or however many you want. If 
everything is filled out, you will then get a 10x3 array, just like a 
spreadsheet.
Since empty fields won't get submitted, you will be missing parts of 
your array. But that's easy to check for.

So for submission your are creating grid contain in one array variable 
skills:
row	skill		skys		Lused
1	C++		3		10/1/2000
2			0		10/21/2004
3	...

Now it's easy to process the grid and check for missing data.
$skills = $_POST['skills'];
//Process each row of the array $skills
//Each row may have up to three elements: skill, skys, Lused
foreach($skills as $skill) {
	//Check if a skill was entered by check for array element named 'skill'
	if(isset($skill['skill'])) {
		$query = 'INSERT INTO dbName (SkilCerts, NumYear, Lused)
VALUES ('.$skill['skill'].', '.$skill['skys'].', 
'.$skill['Lused'].')';
	}
}

On Oct 21, 2004, at 6:55 AM, Stuart Felenstein wrote:
Graham, I'm going to make those changes.  Not sure if
that was creating some crazy behaviour. See inline:
--- Graham Cossey [EMAIL PROTECTED] wrote:

{
if ($skill != '') // Has this skill been
entered?
I don't know if I care if it's been entered.  My main
concern would be to make sure that if a $skill was
entered, then a matching $skys and $slus
should be:
skills[0]-baker skys[0]-7 slus[0]-2002
but wouldn't want
skill[0]-baker skys[1]-7 slus[2]-2002
In other words I need to figure out how to check that
each line is complete.  But~ right now, it is
matching all the values/inputs correctly.  If someone
just chose a slus, seems the database won't take it.
{
  // You may also want to check for sky  slu
entries
Not sure why I would want too:
//$result = mysql_query($query);
$res6 = run_query($query);
echo $query;
  ^^^
  What does this output?
It outputs the insert and values string.
And it seems to print the iteration:
INSERT INTO LurkProfiles_Skicerts (SkicertID,
ProfileID, SkilCerts, NumYear, Lused) VALUES (null,
39, 'a', 2,1)INSERT INTO LurkProfiles_Skicerts
(SkicertID, ProfileID, SkilCerts, NumYear, Lused)
VALUES (null, 39, 'b', 3,2)INSERT INTO
LurkProfiles_Skicerts (SkicertID, ProfileID,
SkilCerts, NumYear, Lused) VALUES (null, 39, 'c',
4,3)INSERT INTO LurkProfiles_Skicerts (SkicertID,
ProfileID, SkilCerts, NumYear, Lused) VALUES (null,
39, 'd', 5,4)INSERT INTO LurkProfiles_Skicerts
(SkicertID, ProfileID, SkilCerts, NumYear, Lused)
VALUES (null, 39, 'e', 6,5)your insertions were
successful
}// end if ($skill != '')
This probably makes sense to add , perhaps that is why
if I don't use all the elements for input I get a
syntax error.
Stuart
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Validation problem with array.

2004-10-20 Thread Graham Cossey
Not sure I really know where you have the problem, but I am assuming you are
trying to construct the INSERT statement within your foreach loop.

If so, why use $_POST[skill[]] when you have $skill which is that current
element being iterated?
Did you read the foreach doc?
http://uk2.php.net/manual/en/control-structures.foreach.php

HTH
Graham


 -Original Message-
 From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
 Sent: 20 October 2004 13:35
 To: [EMAIL PROTECTED]
 Subject: [PHP] Validation problem with array.


 After some back and forth posts here I had finally
 thought my array issue was over, but!

 To review I have 30 form elements on a page
 10 are skill[]
 10 are sky[]
 10 are slu[]

 I pass them as session variables

 $_SESSION['skills'] = $_POST['skill'];
 $_SESSION['skys'] = $_POST['sky'];
 $_SESSION['slus'] = $_POST['slu'];

 Then when everyting is passed into a database
 transaction:

 $skills = $_SESSION['skills'];
 $skys = $_SESSION['skys'];
 $slus = $_SESSION['slus'];

 foreach($_SESSION['skills'] as $key = $skill)
 {
 $query = INSERT INTO Profiles_skills (ProfileID,
 SkilCerts, NumYear, Lused)
 VALUES ($LID, '$skill',
 {$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]});
 //$result = mysql_query($query);

 Here is the problem:

 Using
 (((isset($_POST[skill[]]))?$_POST[skill[]]:) .
 ,true,true,true,true,,false,1);

 I can't seem to differentiate between the the elements
 because they are all labeled skill[]
 So basically validation isn't doing anything .

 I'm thinking of finding a better way to validate , or
 if i change the elements to skill[1], skill[2] , what
 would that do to my iteration loop ?

 Thank you,
 Stuart

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Validation problem with array.

2004-10-20 Thread Stuart Felenstein
My problem is not related to the insert or iteration.
It's related to the validaton of those elements:
skill[]
skill[]
etc.

Clearer ?

Stuart
--- Graham Cossey [EMAIL PROTECTED] wrote:

 Not sure I really know where you have the problem,
 but I am assuming you are
 trying to construct the INSERT statement within your
 foreach loop.
 
 If so, why use $_POST[skill[]] when you have
 $skill which is that current
 element being iterated?
 Did you read the foreach doc?

http://uk2.php.net/manual/en/control-structures.foreach.php
 
 HTH
 Graham
 
 
  -Original Message-
  From: Stuart Felenstein
 [mailto:[EMAIL PROTECTED]
  Sent: 20 October 2004 13:35
  To: [EMAIL PROTECTED]
  Subject: [PHP] Validation problem with array.
 
 
  After some back and forth posts here I had finally
  thought my array issue was over, but!
 
  To review I have 30 form elements on a page
  10 are skill[]
  10 are sky[]
  10 are slu[]
 
  I pass them as session variables
 
  $_SESSION['skills'] = $_POST['skill'];
  $_SESSION['skys'] = $_POST['sky'];
  $_SESSION['slus'] = $_POST['slu'];
 
  Then when everyting is passed into a database
  transaction:
 
  $skills = $_SESSION['skills'];
  $skys = $_SESSION['skys'];
  $slus = $_SESSION['slus'];
 
  foreach($_SESSION['skills'] as $key = $skill)
  {
  $query = INSERT INTO Profiles_skills (ProfileID,
  SkilCerts, NumYear, Lused)
  VALUES ($LID, '$skill',
 

{$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]});
  //$result = mysql_query($query);
 
  Here is the problem:
 
  Using
  (((isset($_POST[skill[]]))?$_POST[skill[]]:)
 .
  ,true,true,true,true,,false,1);
 
  I can't seem to differentiate between the the
 elements
  because they are all labeled skill[]
  So basically validation isn't doing anything .
 
  I'm thinking of finding a better way to validate ,
 or
  if i change the elements to skill[1], skill[2] ,
 what
  would that do to my iteration loop ?
 
  Thank you,
  Stuart
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit:
 http://www.php.net/unsub.php
 
 
 
 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Validation problem with array.

2004-10-20 Thread Graham Cossey
Maybe you would like to post your validation code then.

I (we) do not know where the line:

(((isset($_POST[skill[]]))?$_POST[skill[]]:).,true,true,true,true,
,false,1);

is being called.

Have you thought about using an iteration as you have when constructing the
INSERT statement?
Have you considered placing validation within the iteration you have when
constructing the INSERT statement?

If you do a print_r($skills) you will see that although in the form they are
named skill[] when passed to your script they will be skill[0], skill[1],
skill[2]...

Also, this line :

foreach($_SESSION['skills'] as $key = $skill)

could read

foreach($skills as $key = $skill)

as you have the line:

$skills = $_SESSION['skills'];

Same for skys and slus.

Graham

 -Original Message-
 From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
 Sent: 20 October 2004 14:06
 To: Graham Cossey; [EMAIL PROTECTED]
 Subject: RE: [PHP] Validation problem with array.


 My problem is not related to the insert or iteration.
 It's related to the validaton of those elements:
 skill[]
 skill[]
 etc.

 Clearer ?

 Stuart
 --- Graham Cossey [EMAIL PROTECTED] wrote:

  Not sure I really know where you have the problem,
  but I am assuming you are
  trying to construct the INSERT statement within your
  foreach loop.
 
  If so, why use $_POST[skill[]] when you have
  $skill which is that current
  element being iterated?
  Did you read the foreach doc?
 
 http://uk2.php.net/manual/en/control-structures.foreach.php
 
  HTH
  Graham
 
 
   -Original Message-
   From: Stuart Felenstein
  [mailto:[EMAIL PROTECTED]
   Sent: 20 October 2004 13:35
   To: [EMAIL PROTECTED]
   Subject: [PHP] Validation problem with array.
  
  
   After some back and forth posts here I had finally
   thought my array issue was over, but!
  
   To review I have 30 form elements on a page
   10 are skill[]
   10 are sky[]
   10 are slu[]
  
   I pass them as session variables
  
   $_SESSION['skills'] = $_POST['skill'];
   $_SESSION['skys'] = $_POST['sky'];
   $_SESSION['slus'] = $_POST['slu'];
  
   Then when everyting is passed into a database
   transaction:
  
   $skills = $_SESSION['skills'];
   $skys = $_SESSION['skys'];
   $slus = $_SESSION['slus'];
  
   foreach($_SESSION['skills'] as $key = $skill)
   {
   $query = INSERT INTO Profiles_skills (ProfileID,
   SkilCerts, NumYear, Lused)
   VALUES ($LID, '$skill',
  
 
 {$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]});
   //$result = mysql_query($query);
  
   Here is the problem:
  
   Using
   (((isset($_POST[skill[]]))?$_POST[skill[]]:)
  .
   ,true,true,true,true,,false,1);
  
   I can't seem to differentiate between the the
  elements
   because they are all labeled skill[]
   So basically validation isn't doing anything .
  
   I'm thinking of finding a better way to validate ,
  or
   if i change the elements to skill[1], skill[2] ,
  what
   would that do to my iteration loop ?
  
   Thank you,
   Stuart
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit:
  http://www.php.net/unsub.php
  
  
 
 
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Validation problem with array.

2004-10-20 Thread Stuart Felenstein
Believe it or not I had just thought of doing a
foreach with the validation.

I'll see how it goes.

Stuart
--- Graham Cossey [EMAIL PROTECTED] wrote:

 Maybe you would like to post your validation code
 then.
 
 I (we) do not know where the line:
 

(((isset($_POST[skill[]]))?$_POST[skill[]]:).,true,true,true,true,
 ,false,1);
 
 is being called.
 
 Have you thought about using an iteration as you
 have when constructing the
 INSERT statement?
 Have you considered placing validation within the
 iteration you have when
 constructing the INSERT statement?
 
 If you do a print_r($skills) you will see that
 although in the form they are
 named skill[] when passed to your script they will
 be skill[0], skill[1],
 skill[2]...
 
 Also, this line :
 
 foreach($_SESSION['skills'] as $key = $skill)
 
 could read
 
 foreach($skills as $key = $skill)
 
 as you have the line:
 
 $skills = $_SESSION['skills'];
 
 Same for skys and slus.
 
 Graham
 
  -Original Message-
  From: Stuart Felenstein
 [mailto:[EMAIL PROTECTED]
  Sent: 20 October 2004 14:06
  To: Graham Cossey; [EMAIL PROTECTED]
  Subject: RE: [PHP] Validation problem with array.
 
 
  My problem is not related to the insert or
 iteration.
  It's related to the validaton of those elements:
  skill[]
  skill[]
  etc.
 
  Clearer ?
 
  Stuart
  --- Graham Cossey [EMAIL PROTECTED] wrote:
 
   Not sure I really know where you have the
 problem,
   but I am assuming you are
   trying to construct the INSERT statement within
 your
   foreach loop.
  
   If so, why use $_POST[skill[]] when you have
   $skill which is that current
   element being iterated?
   Did you read the foreach doc?
  
 

http://uk2.php.net/manual/en/control-structures.foreach.php
  
   HTH
   Graham
  
  
-Original Message-
From: Stuart Felenstein
   [mailto:[EMAIL PROTECTED]
Sent: 20 October 2004 13:35
To: [EMAIL PROTECTED]
Subject: [PHP] Validation problem with array.
   
   
After some back and forth posts here I had
 finally
thought my array issue was over, but!
   
To review I have 30 form elements on a page
10 are skill[]
10 are sky[]
10 are slu[]
   
I pass them as session variables
   
$_SESSION['skills'] = $_POST['skill'];
$_SESSION['skys'] = $_POST['sky'];
$_SESSION['slus'] = $_POST['slu'];
   
Then when everyting is passed into a database
transaction:
   
$skills = $_SESSION['skills'];
$skys = $_SESSION['skys'];
$slus = $_SESSION['slus'];
   
foreach($_SESSION['skills'] as $key = $skill)
{
$query = INSERT INTO Profiles_skills
 (ProfileID,
SkilCerts, NumYear, Lused)
VALUES ($LID, '$skill',
   
  
 

{$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]});
//$result = mysql_query($query);
   
Here is the problem:
   
Using
   
 (((isset($_POST[skill[]]))?$_POST[skill[]]:)
   .
,true,true,true,true,,false,1);
   
I can't seem to differentiate between the the
   elements
because they are all labeled skill[]
So basically validation isn't doing anything .
   
I'm thinking of finding a better way to
 validate ,
   or
if i change the elements to skill[1], skill[2]
 ,
   what
would that do to my iteration loop ?
   
Thank you,
Stuart
   
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit:
   http://www.php.net/unsub.php
   
   
  
  
  
 
 
 
 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Validation problem with array.

2004-10-20 Thread Brent Baisley
I think I might know what you are trying to do. You want to have a 
name associated with the skill (or skys or slus). You can use an 
associative array to name your array elements. In your form, you can 
change the array to be something like this:
skills[cooking]
skills[flying]
skills[walking]
...

Notice there are no quotes around the skill names. Now each array 
element has an array key that is a name. The computer doesn't really 
care, but it makes it easier for you to read your code. And you now 
have name/value pairs. You can process the array like this:

$skillNames = array_keys($skills);
foreach($skillNames as $skill) {
echo 'Skill: '.$skill.'  Value: '.$skills[$skill].' br /';
}
Of course, instead of echoing you would do your validation or 
substitution.

On Oct 20, 2004, at 8:35 AM, Stuart Felenstein wrote:
After some back and forth posts here I had finally
thought my array issue was over, but!
To review I have 30 form elements on a page
10 are skill[]
10 are sky[]
10 are slu[]
I pass them as session variables
$_SESSION['skills'] = $_POST['skill'];
$_SESSION['skys'] = $_POST['sky'];
$_SESSION['slus'] = $_POST['slu'];
Then when everyting is passed into a database
transaction:
$skills = $_SESSION['skills'];
$skys = $_SESSION['skys'];
$slus = $_SESSION['slus'];
foreach($_SESSION['skills'] as $key = $skill)
{
$query = INSERT INTO Profiles_skills (ProfileID,
SkilCerts, NumYear, Lused)
VALUES ($LID, '$skill',
{$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]});
//$result = mysql_query($query);
Here is the problem:
Using
(((isset($_POST[skill[]]))?$_POST[skill[]]:) .
,true,true,true,true,,false,1);
I can't seem to differentiate between the the elements
because they are all labeled skill[]
So basically validation isn't doing anything .
I'm thinking of finding a better way to validate , or
if i change the elements to skill[1], skill[2] , what
would that do to my iteration loop ?
Thank you,
Stuart
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Validation problem with array.

2004-10-20 Thread Stuart Felenstein
Brent, 
Thank you , I can't do an associative because it part
of a user input form.  The values will be dependent on
the users.  I'm going to try and give each form
element a index number skill[0], skill[1] since the
foreach loop is doing that anyway.

The reason I haven't posted the validation is because
it's part of a class, so what exists in the page is
only part of the code. 

Stuart


--- Brent Baisley [EMAIL PROTECTED] wrote:

 I think I might know what you are trying to do. You
 want to have a 
 name associated with the skill (or skys or slus).
 You can use an 
 associative array to name your array elements. In
 your form, you can 
 change the array to be something like this:
 skills[cooking]
 skills[flying]
 skills[walking]
 ...
 
 Notice there are no quotes around the skill names.
 Now each array 
 element has an array key that is a name. The
 computer doesn't really 
 care, but it makes it easier for you to read your
 code. And you now 
 have name/value pairs. You can process the array
 like this:
 
 $skillNames   = array_keys($skills);
 foreach($skillNames as $skill) {
   echo 'Skill: '.$skill.'  Value: '.$skills[$skill].'
 br /';
 }
 
 Of course, instead of echoing you would do your
 validation or 
 substitution.
 
 On Oct 20, 2004, at 8:35 AM, Stuart Felenstein
 wrote:
 
  After some back and forth posts here I had finally
  thought my array issue was over, but!
 
  To review I have 30 form elements on a page
  10 are skill[]
  10 are sky[]
  10 are slu[]
 
  I pass them as session variables
 
  $_SESSION['skills'] = $_POST['skill'];
  $_SESSION['skys'] = $_POST['sky'];
  $_SESSION['slus'] = $_POST['slu'];
 
  Then when everyting is passed into a database
  transaction:
 
  $skills = $_SESSION['skills'];
  $skys = $_SESSION['skys'];
  $slus = $_SESSION['slus'];
 
  foreach($_SESSION['skills'] as $key = $skill)
  {
  $query = INSERT INTO Profiles_skills (ProfileID,
  SkilCerts, NumYear, Lused)
  VALUES ($LID, '$skill',
 

{$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]});
  //$result = mysql_query($query);
 
  Here is the problem:
 
  Using
  (((isset($_POST[skill[]]))?$_POST[skill[]]:)
 .
  ,true,true,true,true,,false,1);
 
  I can't seem to differentiate between the the
 elements
  because they are all labeled skill[]
  So basically validation isn't doing anything .
 
  I'm thinking of finding a better way to validate ,
 or
  if i change the elements to skill[1], skill[2] ,
 what
  would that do to my iteration loop ?
 
  Thank you,
  Stuart
 
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit:
 http://www.php.net/unsub.php
 
 
 -- 
 Brent Baisley
 Systems Architect
 Landover Associates, Inc.
 Search  Advisory Services for Advanced Technology
 Environments
 p: 212.759.6400/800.759.0577
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Validation problem with array.

2004-10-20 Thread Brent Baisley
I thought you were using checkboxes based on your true/false. So the 
user is actually typing in skills?

Not sure where you are going with skill[0], skill[1]. You are creating 
an associative array when you do that. In and input form, skill[0] and 
skill[a] are actually no different, aside from the name you are using 
for that element.

On Oct 20, 2004, at 9:41 AM, Stuart Felenstein wrote:
Brent,
Thank you , I can't do an associative because it part
of a user input form.  The values will be dependent on
the users.  I'm going to try and give each form
element a index number skill[0], skill[1] since the
foreach loop is doing that anyway.
The reason I haven't posted the validation is because
it's part of a class, so what exists in the page is
only part of the code.
Stuart
--- Brent Baisley [EMAIL PROTECTED] wrote:
I think I might know what you are trying to do. You
want to have a
name associated with the skill (or skys or slus).
You can use an
associative array to name your array elements. In
your form, you can
change the array to be something like this:
skills[cooking]
skills[flying]
skills[walking]
...
Notice there are no quotes around the skill names.
Now each array
element has an array key that is a name. The
computer doesn't really
care, but it makes it easier for you to read your
code. And you now
have name/value pairs. You can process the array
like this:
$skillNames = array_keys($skills);
foreach($skillNames as $skill) {
echo 'Skill: '.$skill.'  Value: '.$skills[$skill].'
br /';
}
Of course, instead of echoing you would do your
validation or
substitution.
On Oct 20, 2004, at 8:35 AM, Stuart Felenstein
wrote:
After some back and forth posts here I had finally
thought my array issue was over, but!
To review I have 30 form elements on a page
10 are skill[]
10 are sky[]
10 are slu[]
I pass them as session variables
$_SESSION['skills'] = $_POST['skill'];
$_SESSION['skys'] = $_POST['sky'];
$_SESSION['slus'] = $_POST['slu'];
Then when everyting is passed into a database
transaction:
$skills = $_SESSION['skills'];
$skys = $_SESSION['skys'];
$slus = $_SESSION['slus'];
foreach($_SESSION['skills'] as $key = $skill)
{
$query = INSERT INTO Profiles_skills (ProfileID,
SkilCerts, NumYear, Lused)
VALUES ($LID, '$skill',

{$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]});
//$result = mysql_query($query);
Here is the problem:
Using
(((isset($_POST[skill[]]))?$_POST[skill[]]:)
.
,true,true,true,true,,false,1);
I can't seem to differentiate between the the
elements
because they are all labeled skill[]
So basically validation isn't doing anything .
I'm thinking of finding a better way to validate ,
or
if i change the elements to skill[1], skill[2] ,
what
would that do to my iteration loop ?
Thank you,
Stuart
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit:
http://www.php.net/unsub.php

--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology
Environments
p: 212.759.6400/800.759.0577
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Validation problem with array.

2004-10-20 Thread Stuart Felenstein
Yes I just found that out :).
Back to the drawing board!.

Stuart
--- Brent Baisley [EMAIL PROTECTED] wrote:

 I thought you were using checkboxes based on your
 true/false. So the 
 user is actually typing in skills?
 
 Not sure where you are going with skill[0],
 skill[1]. You are creating 
 an associative array when you do that. In and input
 form, skill[0] and 
 skill[a] are actually no different, aside from the
 name you are using 
 for that element.
 
 
 On Oct 20, 2004, at 9:41 AM, Stuart Felenstein
 wrote:
 
  Brent,
  Thank you , I can't do an associative because it
 part
  of a user input form.  The values will be
 dependent on
  the users.  I'm going to try and give each form
  element a index number skill[0], skill[1] since
 the
  foreach loop is doing that anyway.
 
  The reason I haven't posted the validation is
 because
  it's part of a class, so what exists in the page
 is
  only part of the code.
 
  Stuart
 
 
  --- Brent Baisley [EMAIL PROTECTED] wrote:
 
  I think I might know what you are trying to do.
 You
  want to have a
  name associated with the skill (or skys or
 slus).
  You can use an
  associative array to name your array elements.
 In
  your form, you can
  change the array to be something like this:
  skills[cooking]
  skills[flying]
  skills[walking]
  ...
 
  Notice there are no quotes around the skill
 names.
  Now each array
  element has an array key that is a name. The
  computer doesn't really
  care, but it makes it easier for you to read your
  code. And you now
  have name/value pairs. You can process the array
  like this:
 
  $skillNames= array_keys($skills);
  foreach($skillNames as $skill) {
 echo 'Skill: '.$skill.'  Value:
 '.$skills[$skill].'
  br /';
  }
 
  Of course, instead of echoing you would do your
  validation or
  substitution.
 
  On Oct 20, 2004, at 8:35 AM, Stuart Felenstein
  wrote:
 
  After some back and forth posts here I had
 finally
  thought my array issue was over, but!
 
  To review I have 30 form elements on a page
  10 are skill[]
  10 are sky[]
  10 are slu[]
 
  I pass them as session variables
 
  $_SESSION['skills'] = $_POST['skill'];
  $_SESSION['skys'] = $_POST['sky'];
  $_SESSION['slus'] = $_POST['slu'];
 
  Then when everyting is passed into a database
  transaction:
 
  $skills = $_SESSION['skills'];
  $skys = $_SESSION['skys'];
  $slus = $_SESSION['slus'];
 
  foreach($_SESSION['skills'] as $key = $skill)
  {
  $query = INSERT INTO Profiles_skills
 (ProfileID,
  SkilCerts, NumYear, Lused)
  VALUES ($LID, '$skill',
 
 
 

{$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]});
  //$result = mysql_query($query);
 
  Here is the problem:
 
  Using
 
 (((isset($_POST[skill[]]))?$_POST[skill[]]:)
  .
  ,true,true,true,true,,false,1);
 
  I can't seem to differentiate between the the
  elements
  because they are all labeled skill[]
  So basically validation isn't doing anything .
 
  I'm thinking of finding a better way to validate
 ,
  or
  if i change the elements to skill[1], skill[2] ,
  what
  would that do to my iteration loop ?
 
  Thank you,
  Stuart
 
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit:
  http://www.php.net/unsub.php
 
 
  -- 
  Brent Baisley
  Systems Architect
  Landover Associates, Inc.
  Search  Advisory Services for Advanced
 Technology
  Environments
  p: 212.759.6400/800.759.0577
 
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit:
 http://www.php.net/unsub.php
 
 
 
 
 -- 
 Brent Baisley
 Systems Architect
 Landover Associates, Inc.
 Search  Advisory Services for Advanced Technology
 Environments
 p: 212.759.6400/800.759.0577
 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php