dolcezza Posted January 16, 2008 Share Posted January 16, 2008 I wanted to put the array(mileage,hotel...) in the database and I am getting the word "array". 'm confused as to how to get it to put in the values. (posting only relevant code). I moved this from the php forum because it is going into the databae as "array". It is 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> then used as: $travelinc = ($_POST['travelinc']); $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'"; $how_many = count($travelinc); if ($how_many>0) { $travelinc = 'N/A'; } for ($i=0; $i<$how_many; $i++) { $pdf->MultiCell(0,5, $travelinc[$i] . ", ",0,0); Link to comment https://forums.phpfreaks.com/topic/86227-putting-array-in-mysql-field/ Share on other sites More sharing options...
fenway Posted January 16, 2008 Share Posted January 16, 2008 You can't -- that is, you shouldn't. Link to comment https://forums.phpfreaks.com/topic/86227-putting-array-in-mysql-field/#findComment-440449 Share on other sites More sharing options...
dolcezza Posted January 16, 2008 Author Share Posted January 16, 2008 even if the only way I am using it is as an array? I just need to be able to print it as : travel expenses include: mileage, hotel.... Link to comment https://forums.phpfreaks.com/topic/86227-putting-array-in-mysql-field/#findComment-440452 Share on other sites More sharing options...
jaymc Posted January 16, 2008 Share Posted January 16, 2008 $doit = serialize($thearray) put that in the field, will look like shit then pull it out and do $redoit = unserialize($data[field]) Bang, you got your array back Link to comment https://forums.phpfreaks.com/topic/86227-putting-array-in-mysql-field/#findComment-440457 Share on other sites More sharing options...
dolcezza Posted January 16, 2008 Author Share Posted January 16, 2008 I am both inserting it, and using it on the same page... so if I serialize, then insert, I can still use unserialize even though I am not pulling it out of the database? In which case would it be something like: $redoit = unserialize($doit) ? Link to comment https://forums.phpfreaks.com/topic/86227-putting-array-in-mysql-field/#findComment-440459 Share on other sites More sharing options...
fenway Posted January 17, 2008 Share Posted January 17, 2008 It's still a poor choice. Link to comment https://forums.phpfreaks.com/topic/86227-putting-array-in-mysql-field/#findComment-441464 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.