Problem w/query - again

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

 



Dear list -

This did not seem to post, so I am sending it again.

If it did post, and I missed it, my apologies.

Ethan
============
Dear list -

I have the following code:

$query = "select * from Intake3 where  1";

$allowed_fields = array('Site', 'MedRec', 'Fname', 'Lname',
                        'Phone', 'Sex', 'Height');

foreach ( $allowed_fields AS $field => $_POST['field'])
{
        if ( ! empty( $_POST['field'] ) )
        {
                $query .= " AND '$field' = '$_POST[$field]' ";
                echo $query;
        }
}

This is the value of $_POST:


 Array
(
    [Site] => AA
    [MedRec] => 10000
    [Fname] =>
    [Lname] =>
    [Phone] =>
    [Height] =>
    [welcome_already_seen] => already_seen
)

I receive the following errors on run:



 Notice: Undefined offset: 0 in /var/www/srchrhsptl4.php on line 135
select * from Intake3 where  1 AND '0' = ''
Notice: Undefined offset: 1 in /var/www/srchrhsptl4.php on line 135
select * from Intake3 where  1 AND '0' = ''  AND '1' = ''
Notice: Undefined offset: 2 in /var/www/srchrhsptl4.php on line 135
select * from Intake3 where  1 AND '0' = ''  AND '1' = ''  AND '2' = ''

Advice and help please.

Thanks.


Ethan





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



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux