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

Reply via email to