Thanks mike! that did the trick. This works:

/* this gets rid of the last element of $_POST which is 'addentry' from the form's submit button. $_POST now containes ONLY the values expected by pg_insert. By the way, the order of the values in $_POST does not seem to matter, only that there are exactly as many as there are columns in the table and their names match the columns exactly.*/

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

On Mon, 22 Aug 2005, mike burnard wrote:

It very likely is the error. you can use array_pop($_POST); to remove that last line. You can always have your insert function return an error on failure. <snip />

By the way Bastian and John, thanks for responding to my pg_connect question some days ago. Installing Marc Liyanage's distribution did the trick!

Thanks too to Bastian and Micah.

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


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
( 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
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


I'm not sure what any of this means, but it didn't turn out to be necessary.


PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to