arupratan biswas wrote:
> $sqlstatement="INSERT INTO new_user
> (emp_id,emp_name,emp_add,city,zip_code,dob,phone)
> VALUES('$emp_id','$emp_name','$emp_add','$city',$zip_code,'$dob','$phone')";
> $sth = $dbh->prepare($sqlstatement);
> $sth->execute ||
> die "Could not execute SQL statement ... maybe invalid?";
In my personal view, the above is bad coding practice. I always use placeholders:
my $sqlstatement = qq{
INSERT INTO new_user
(emp_id, emp_name, emp_add, city, zip_code, dob, phone)
VALUES(?, ?, ?, ?, ?, ?, ?)
};
my $sth = $dbh->prepare($sqlstatement) or die "Could not prepare statement: $DBI::errstr";
$sth->execute($emp_id, $emp_name, $emp_add, $city, $zip_code, $dob, $phone)
or die "Could not execute: $DBI::errstr;
In your case, add the value of your sql statement to the die message, to see if the insert contains what you think it contains:
... die "Could not execute '$sqlstatement' ...";
--
felix
Please use
BBCode to format your messages in this forum.