foreach

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

 



Dear Lists -

I know I am missing something fundamental - but I have no idea where to start to look.

Here are code snippets:

I have truncated the allowed_fields to make it easier to debug.

$allowed_fields = array( 'Site' =>'POST[Site]', 'MedRec' => '$_POST[MedRec]', 'Fname' => '$_POST[Fname]' );
 echo "post #1\n";
 print_r($_POST);

RESPONSE:

 post #1
Array
(
    [Site] => AA
    [MedRec] => 10002
    [Fname] =>
    [Lname] =>
    [Phone] =>
    [Height] =>
    [welcome_already_seen] => already_seen
    [next_step] => step10
)



// $allowed_fields = array("Site", "MedRec", "Fname", "Lname", // previous statement of $allowed_fields
  //                      "Phone", "Sex", "Height");



Key Site, Value POST[Site]
Key MedRec, Value $_POST[MedRec]
Key Fname, Value $_POST[Fname]



foreach ($allowed_fields as $key => $val) {
    print "Key $key, Value $val\n";
}


        if(isset($_Request['Sex'])&& trim($_POST['Sex']) != '' )
        {
                if ($_REQUEST['Sex'] === "0")
                {
                        $sex = 'Male';
                }
                else
                {
                        $sex = 'Female';
                }
        }
 }
                echo "Post#2";
                print_r($_POST);
                   if(empty($allowed_fields))
//RESPONSE

Post#2Array
(
    [Site] => AA
    [MedRec] => 10002
    [Fname] =>
    [Lname] =>
    [Phone] =>
    [Height] =>
    [welcome_already_seen] => already_seen
    [next_step] => step10
)



   {
     echo "ouch";
   }

foreach ( $allowed_fields as $key => $val ) //This is line 198
{
        if ( ! empty( $_POST['val'] ) )
        {
                print "Key $key, Value $val\n";
                        $cxn = mysqli_connect($host,$user,$password,$db);
                $value = mysql_real_escape_string( $_POST[$fld] );
                $query .= " AND $fld = '$_POST[value]' ";
               echo "#1 $query"; //never echos the query
        }
}

These are the messages I receive on execution of the script:

Notice: Undefined variable: allowed_fields in /var/www/srchrhsptl5.php on line 198 Warning: Invalid argument supplied for foreach() in /var/www/srchrhsptl5.php on line 198

Advice and help, please.

Thank you.

Ethan Rosenberg




--
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