Hi all,
I have a problem using a hash variable and I don't know where is the error.
Let me explain it: I have a web page with a form which user must fill in
with personal data then when the user click 'Send' button the cgi I am
programming starts; I have a txt file containing the name of the fields of
the form which match with the name of the fields in the table I want to
insert data so first thing I am doing in the cgi is obtaining data typed by
the user in the form and I store it in a hash named %postInputs; then I use
a function to initialize an array with the fields in the text file so the
name of the array is @fields. No I am using next function to insert data in
the table:
...
%postInputs = readPostInput();
readFields(@fields);
...
insertData();
...
sub insertData()
{
my $base_datos = $fields[0];
my $driver = "mysql";
my $tabla = $fields[1];
my $sql_inserta="INSERT INTO $tabla (dia_alta,
mes_alta,
anno_alta,
$fields[2])
VALUES ('$mday',
'$mon',
'$year',
'$postInputs{'$fields[2]'}')"; #
(*) HERE IS THE PROBLEM
my ($dbh) = DBI->connect("DBI:$driver:table_name") || die "\nError al
abrir la base de datos: $dbh->errstr()\n";
$dbh->do($sql_inserta) || die "prepare: " . $dbh->errstr();
$dbh->disconnect || warn "\nError al desconectar.\nError:
$DBI::errstr\n";
}
Then when I execute this function, data is inserted into the table except
the field I mark (*). If I use ...,'nombre')" it works and insert this data
into the table.
On the other hand, in the DBI->connect sentence I have another problem
because I must use DBI->connect("DBI:$driver:table_name") and I want to use
DBI->connect("DBI:$driver:$base_datos"). I think the problem is the same.
Please, does anyone know how can I solve this problem?.
Many thanks for your help.
[EMAIL PROTECTED]
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com