Forum Moderators: coopster

Message Too Old, No Replies

Having trouble form posting some information

keep getting a bool value instead of character/number

         

will1480

4:38 am on May 23, 2004 (gmt 0)

10+ Year Member



I am trying to send a value from a form to another page to insert the value into a database/table.

here is the form code created by PHP:
print "<select name='".$l."'>";
print "<option selected value='0'>0</option><option value='0'>--</option>";
for($m=1;$m<=10;$m++){
print "<option value='".$m."'>".$m."</option>";
}
//$m is value for option
//$l is a unique variable for this pull down

here is page that takes form info. and puts into an array:
while (list ($key, $val) = each ($HTTP_POST_VARS)){
//add the form values except for the $user_id
if($val!=$_SESSION['user_id']){
array_push($array_temp,$val);
}}

Here is the variable dump for that array:
array(21) { [0]=> string(9) "BBG-A4055" [1]=> bool(false) [2]=> ...bunch more variables

____________________________________
It returns a submitted value of '0' no problem, but anything other than '0' is stores some boolean value. Anyone know why this is? I had it working before and must have changed something, but I am stumped :(

Birdman

12:22 pm on May 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not positive it will work, but most likely you just need to force the variable to be of the integer type. You should be able to do this:

if($val!=$_SESSION['user_id']){
array_push($array_temp,int($val));
}

added:

Actually, that won't work because it'll make all the vars int, and you have strings in there too.

You'll have to test for the problem var and then only apply the int type to it.

if($val!=$_SESSION['user_id']){
if($key == "dropdown name") array_push($array_temp,int($val));
else array_push($array_temp,$val);
}

Hope it helps.

will1480

4:10 pm on May 24, 2004 (gmt 0)

10+ Year Member



Not sure what the problem was to tell you the truth. I just reverted back to my old code and it worked. I will keep taht in mind for next time. Thanks.