Or if you need to store all the values, you could normalize the table field 
into another table.

-Micah 

On Monday 22 August 2005 3:19 pm, Bastien Koert wrote:
> To further append the previous note,
>
> if you want to insert the array, you need to serialize it
> (www.php.net/serialize) to make the array db safe
>
> if you want to insert the individual specific values, you will need to
> implode the array with separators (and check the data in the correct order
> for the field list) or you will need to supply a field list that matches
> the array list to ensure the data elements are placed into the correct
> columns
>
> Bastien
>
> >From: Jon Crump <[EMAIL PROTECTED]>
> >To: php-db@lists.php.net
> >Subject: [PHP-DB] pg_insert tyro question
> >Date: Mon, 22 Aug 2005 14:34:03 -0700 (PDT)
> >
> >Being a tyro, I'm sure I'm missing something obvious about handling the
> >array $_POST. I hope wiser heads can point me in the right direction.
> >
> >This fails:
> >
> ><?php
> >$db = pg_connect( "dbname=foo user=bar" );
> >
> >if( $db )
> >{
> >   print "Successfully connected to port: " . pg_port($db) ."<br/>\n";
> >} else {
> >   print pg_last_error ($db);
> >   exit;
> >}
> >
> >$res = pg_insert($db, 'vracore', $_POST);
> >if ($res) {
> >     echo "You're a Genius";
> >} else {
> >   print_r ($_POST);
> >   exit;
> >}
> >
> >pg_Close( $db );
> >?>
> >
> >The connection string works fine. If I insert each field in $_POST
> >separately, that works fine too eg.
> >
> >$value1=$_POST['value1'];
> >$value1=$_POST['value2'];
> >etc...
> >
> >$query = "insert into foo (columnname1, columnname2, etc...) values
> >($value1, $value2, etc...);";
> >
> >$result = pg_exec($db, $query);
> >
> >But if I try pg_insert($db, 'foo', $_POST);
> >
> >it fails. I note that print_r ($_POST) returns a list of values that
> >includes  [addentry] => Add Entry from the submit button. Is that what's
> >screwing it up?
> >
> >Any clues would be much appreciated.
> >
> >Jon
> >
> >--
> >PHP Database Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to