RE: Validation problem with array.

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

 



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, 'aaaaa', 2,1)INSERT INTO LurkProfiles_Skicerts
> (SkicertID, ProfileID, SkilCerts, NumYear, Lused)
> VALUES (null, 39, 'bbbbb', 3,2)INSERT INTO
> LurkProfiles_Skicerts (SkicertID, ProfileID,
> SkilCerts, NumYear, Lused) VALUES (null, 39, 'ccccc',
> 4,3)INSERT INTO LurkProfiles_Skicerts (SkicertID,
> ProfileID, SkilCerts, NumYear, Lused) VALUES (null,
> 39, 'ddddd', 5,4)INSERT INTO LurkProfiles_Skicerts
> (SkicertID, ProfileID, SkilCerts, NumYear, Lused)
> VALUES (null, 39, 'eeeee', 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, 'aaaaa', 2,1)
Query 1 = INSERT INTO LurkProfiles_Skicerts (SkicertID, ProfileID,
SkilCerts, NumYear, Lused) VALUES (null,9, 'bbbbb', 3,2)
Query 2 = INSERT INTO LurkProfiles_Skicerts (SkicertID, ProfileID,
SkilCerts, NumYear, Lused) VALUES (null, 9, 'ccccc', 4,3)
Query 3 = INSERT INTO LurkProfiles_Skicerts (SkicertID, ProfileID,
SkilCerts, NumYear, Lused) VALUES (null,39, 'ddddd', 5,4)
Query 4 = INSERT INTO LurkProfiles_Skicerts (SkicertID, ProfileID,
SkilCerts, NumYear, Lused) VALUES (null, 9, 'eeeee', 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


[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