To further append the previous note,

if you want to insert the array, you need to serialize it ( 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


From: Jon Crump <[EMAIL PROTECTED]>
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:

$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);

$res = pg_insert($db, 'vracore', $_POST);
if ($res) {
        echo "You're a Genius";
} else {
  print_r ($_POST);

pg_Close( $db );

The connection string works fine. If I insert each field in $_POST separately, that works fine too eg.


$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.


PHP Database Mailing List (
To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to