Good to see you back m@tt; you’ve been a big help to my learning process.
Most comments have been removed. This is a section of the larger main code. It runs with the following output: (The script has some residual, trivial code I used to understand what happens to an array.) L. 144 is marked
##<<.
----output----
L8. RGSTRTN_06.php Tuesday 05th of March 2013 11:09:11 AM
Tuesday 05th of March 2013 11:09:11 AM L.156 $buffer is an array
Key US Value United States L. 166 Key US Value United States is an array
L.169 $buffer is not an array
string(26) "Key AF Value Afghanistan
"
Fatal error: Uncaught exception 'ErrorException' with message 'Undefined offset: 5' in /home/vg011web00/68/65/2926568/web/auxlib/usit2013/snip_test.php:134 Stack trace: #0 /home/vg011web00/68/65/2926568/web/auxlib/usit2013/snip_test.php(134): exception_error_handler(8, 'Undefined offse...', '/home/vg011web0...', 134, Array) #1 {main} thrown in /home/vg011web00/68/65/2926568/web/auxlib/usit2013/snip_test.php on line 134
[php]<?php //snip_test.php
// www.u-sit.net/auxlib/web07/HTMLpages/RGSTRTN_06.php
session_start();
include_once ($_SERVER['DOCUMENT_ROOT'] . '/lib/php/cnnct2mysql.php');
$time_stamp = date('l dS \of F Y h:i:s A ');
echo 'L8. RGSTRTN_06.php ’ .date(‘l dS \of F Y h:i:s A ‘),’
’;
$notify_email = ‘[email protected]’;
?>
RGSTRTN_06.php Send Registration data to DBs. Includes mailing of freebies & June07 US Postal rates
<?PHP
if (!session_is_registered("counted"))
{mysql_query("UPDATE hitcounter SET count=(count + 1) WHERE count_id=1");
session_register("counted");
}
error_reporting (E_ALL ^ E_NOTICE);
//echo ($_SERVER{'DOCUMENT_ROOT'}); // /home/68/65/2926568/web
include_once ($_SERVER{'DOCUMENT_ROOT'} . '/auxlib/usit2013/SMTP4PHP.php');
/*
$hit_query = "SELECT count FROM hitcounter";
$hit_result = mysql_query($hit_query);
$hits = mysql_fetch_assoc($hit_result);
foreach ($hits as $key => $value){
$hit = $value;
//echo "key = $key, ID = $ID
";
}
*/
echo date('l dS \of F Y h:i:s A '); //
// $fp = fsockopen ('www.sandbox.paypal.com', 80, $errno, $errstr, 30);
foreach ($_POST as $key => $value) {
echo (isset($_POST["submit"]) ? $key= $value : null) . '
';
}
/*
$invoiceNo = $_POST['invoiceNo'];
$amount = $_POST['amount'];
$item_name = $_POST['item_name'];
$email = $_POST['email'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$country = $_POST['country'];
$mc_gross = $_POST['mc_gross'];
$mc_fee = $_POST['mc_fee'];
$tax = $_POST['tax'];
$s_h = $_POST['S_H'];
$affiliation = $_POST['affiliation'];
$degree = $_POST['degree'];
$occupation = $_POST['occupation'];
$specialty = $_POST['specialty'];
$Nwsltr = $_POST['Nwlstr'];
$USIT_txt = $_POST['USIT_txt'];
$USIT_ovr_En = $_POST['USIT_ovr_En']; //use 'e', 's', 'es' ?
$USIT_ovr_Sp = $_POST['USIT_ovr_Sp'];
$HI_txt = $_POST['HI_txt'];
$USIT_HI = $_POST['USIT_HI'];
$Nwsl_En = $_POST['Nwsl_En'];
$Nwsl_Sp = $_POST['Nwsl_Sp'];
$EnNL01_10 = $_POST['EnNL01_10'];
$SpNL01_19 = $_POST['SpNL01_19'];
$EnNL11_20 = $_POST['EnNL11_20'];
$SpNL01_54 = $_POST['SpNL01_54'];
$EnNL21_30 = $_POST['EnNL21_30'];
$EnNL31_40 = $_POST['EnNL31_40'];
$EnNL41_50 = $_POST['EnNL41_50'];
$EnNL51_60 = $_POST['EnNL51_60'];
$EnNL61_70 = $_POST['EnNL61_70'];
$EnNL71_80 = $_POST['EnNL71_80'];
$payment_date = $time_stamp;
*/
// B. Prepare Country- & State-select tags (Courtesy David Kirol) //
$a = array(); // a list of country choices and their 2-char codes
$buffer = array();
if (is_array($buffer)) echo 'L.156 $buffer is an array
';
//$a[" "] = ''; // first element is blank - forces user to select one of a displayed list
$fh = fopen($_SERVER{'DOCUMENT_ROOT'} . '/auxlib/web07/InclReq/kvpisow2.txt', "r");
$buffer = fgets($fh);
if (is_array($buffer)){
foreach($buffer as $k => $v) {if(!isset($v)) $v = null ;}
} else {
echo "
$buffer L. 166 $buffer is an array
";
}
$buffer = fgets($fh);
echo (is_array($buffer) ? 'L.169 $buffer is array
' : 'L.169 $buffer is not an array
');
echo '
', var_dump($buffer) , '
';
while ($buffer = fgets($fh))
{
$kvp = preg_split ("/[\s,]+/", $buffer); // Split buffer on any combination of spaces or commas.
$a["$kvp[1]"] = $kvp[3] . " " . $kvp[4] . " " . $kvp[5] . " " . $kvp[6] . " " . $kvp[7] . " " ##ERROR THROWN Here
. $kvp[8];
}
fclose ($fh);
//////////////////// ++++++++++++++ End of Country prep +++++++++++++ ////////////////
?>
[/php]