RE: Validation problem with array.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



See below:
--- Graham Cossey <graham@xxxxxxxxxxxxxxx> 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 I"m 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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux