Re: Re: foreach

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

 



Send the code around line 198, say 170 to 210.

On Apr 5, 2012, at 8:42 PM, Al wrote:

> 
> 
> On 4/5/2012 4:15 PM, Ethan Rosenberg wrote:
>> 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
>> 
> 
> Break down you code into workable segments and test each one individually. If you have a problem with a small segment, ask for help about it specifically.
> 
> Folks don't have time to digest and critique your whole code.
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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