[KLUG Members] php 4.3.10, correction

Lunitix lunitix at earthlink.net
Sat Jan 29 10:24:52 EST 2005


> That's because $_POST["add_score"] is being used in an "if" statement
> (which can contain 0, null, or nothing and evaluate correctly as
> "false").  An "each" statement, however, requires an array (if it
> doesn't get an array it errors).
> 
> Hope I've fixed up any confusion I've caused.

I believe I am the more confused here.  But that being said, thanks for 
showning me that it was a lack value being sent to the $_POST[sub_score] 
that was creating the error on this page.  I used this to remedy the 
situation -

if ($_POST["add_score"]) {
	//calculating scores
	//print_r($_POST);
	list($key,$val)=each($_POST["add_score"]);
	$val=$val+$_POST["curval"];
	$sqlstring = "$key=$val";
----->		if ($_POST["sub_score"]) {
			$scoreval=TRUE;
		} else {
thru			$scoreval=FALSE;
		}
		if ($scoreval) {
		while (list($key,$val)=each($_POST["sub_score"])) {
				$val=$val-$_POST["curval"];
				$sqlstring .= ",  $key=$val";
----->		} //end if for null "sub_score"
	}  // end while


And also, the help with the null $sql (changed to $sql="") in my 
connecttodb.inc was very helpful.

Jon
Minding of Madness


More information about the Members mailing list