Page 1 of 1

using generated form names in a new form

Posted: Fri Mar 05, 2004 4:44 am
by redtux
I have a form which generates a table form with form fields names on the fly

ie: I do a query on a Pg db and then name several iterations of a form as [fieldname]'. $row . '

My problem is how do I use this in the submit form

If I do CASE statements quoting eg id1 id2 id3 then my update works

My question is is it possible to do this by referring to eg id.$row .' ie how the names are defined in the previous form

This is my current code

Code: Select all

<?php
$db = pg_connect("dbname=data_cc");
$id_chg=$_POST("id'. $row .'");
$firstchg=$_POST("$firstname'. $row .'");
$query = "UPDATE tb_contacts SET first_name='$firstchg' WHERE contact_id='$id_chg'";
$result = pg_exec($db, $query);
if (!$result) &#123;
printf ("ERROR");
$errormessage = pg_errormessage($db);
echo $errormessage;
exit;
&#125;
printf ("These values were updated in the database - ");
pg_close();
?>
This is the error that comes from running the script in a terminal.
PHP Notice: Array to string conversion in /home/www/html/update1.php on line 3
PHP Fatal error: Call to undefined function: array() in /home/www/html/update1.php on line 3
Content-type: text/html
X-Powered-By: PHP/4.3.4