Jump to content

[SOLVED] getting the word "array" not the value


dolcezza

Recommended Posts

Can someone help me get the names "hotel" or whatever when checked...I am getting the word "array"

Help for a newbie... greatly appreciated.

 

<input type="text" size="15" name="travelexp" id="travelexp">
       <input type="checkbox" name="travelinc[]" value="mileage">mileage <input type="checkbox" name="travelinc[]" value="flight">flight <input type="checkbox" name="travelinc[]" value="hotel">hotel <input type="checkbox" name="travelinc[]" value="perdiem">per diem</p>

 

$travelinc = ($_POST['travelinc']);
$how_many = count($travelinc);
	if ($how_many>0) {
	$travelinc = 'N/A';
        }
        for ($i=0; $i<$how_many; $i++) {
			$pdf->MultiCell(0,5, $travelinc . ", ",0,0);
        } 

Link to comment
Share on other sites

the word "array" is in the database... this shouldn't be, right?

It must be the way it is going in?

$query = "UPDATE events SET address='$address', city='$city', state='$state', zip='$zip', directions='$directions', honorarium='$honorarium', travelexp='$travelinc', sig='$sig', other='$eventnotes' WHERE eventid = '$eventid'";

Link to comment
Share on other sites

it's coming from

<input type="checkbox" name="travelinc[]" value="mileage">mileage <input type="checkbox" name="travelinc[]" value="flight">flight <input type="checkbox" name="travelinc[]" value="hotel">hotel <input type="checkbox" name="travelinc[]" value="perdiem">per diem</p>

Link to comment
Share on other sites

ok... someone over in mysql said to serialize it to put it into the database, no prob.

 

but I want to use it directly from the form.

The following code is almost there, it says "array mileage, travel"

how can I get rid of the word array?

foreach($_POST['travelinc']  as  $value)  {
$travelinc .= " $value, ";
} 

Link to comment
Share on other sites

$travelinc = ($_POST['travelinc']);
$how_many = count($travelinc);
	if ($how_many>0) {
	$travelinc = 'N/A';
        }
        for ($i=0; $i<$how_many; $i++) {
			$pdf->MultiCell(0,5, $travelinc . ", ",0,0);
        } 

Why would you say $travelinc is equal to 'N/A' if $how_many is greater than 0? ???

 

If you want to get the array items as a string, I think you can just do this:

<?php
$travelinc = implode(",", $_POST['travelinc']);
?>

 

If you want to serialize it, you can.

Link to comment
Share on other sites

foreach($_POST['travelinc']  as  $value)  {
$travelinc .= " $value, ";
} 

That could give you problems if you have register_globals on.

 

try

$user_travelinc_choices = implode(",",$_POST['travelinc']);

 

That will give you a comma separated string to insert into a db field.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.