> FYI: Make sure you addslashes() _after_ you serialize your array if it can
> contain quotes. Everything else remains the same.
Yeah, my bad. Good catch.
Chris
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
> > How would I store an array in the database? I want to store 2 things.
> > One array of shirt sizes and one array of which holds other arrays.
[snip]
> $query = "INSERT INTO table
> ( field1, field2 )
> VALUES
> ( \"" . serialize( $singleDimA
> How would I store an array in the database? I want to store 2 things.
> One array of shirt sizes and one array of which holds other arrays.
$safe = addslashes(serialize($array));
and store $safe into a text column. Use
$array = unserialize($database_data);
to get the array back.
---John H
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Storing an array in the database
> How would I store an array in the database? I want to store 2 things.
> One array of shirt sizes and one array of which holds other arrays.
Easy.
$singleDimArray = array( 1, 2
> How would I store an array in the database? I want to store 2 things.
> One array of shirt sizes and one array of which holds other arrays.
Easy.
$singleDimArray = array( 1, 2, 3, 4, 5 );
$multiDimArray = array( array( "this" => "that", "here" => "there" ),
t me know!
Ignatius
- Original Message -
From: "Jonathan Villa" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, February 28, 2003 5:09 PM
Subject: [PHP-DB] Storing an array in the database
>
> How would I store an array in the database? I want to st
just as a quick fix. I use the following snip to take an array of
choices, enter it into a varchar field (or text if you expect alot) and
extract back to array:
$choicesArray is a list of checkboxes from a form
// put data into table
$checkList = implode(";", $choicesArray);
mysql_query("upd
x27;m just lazy. ;^)
HTH
Rich
> -Original Message-
> From: Jonathan Villa [mailto:[EMAIL PROTECTED]
> Sent: Friday, February 28, 2003 11:10 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Storing an array in the database
>
>
>
> How would I store an array in the
How would I store an array in the database? I want to store 2 things.
One array of shirt sizes and one array of which holds other arrays.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php