MySQL Forums
Forum List  »  Perl

Re: fetch a problem to insert values in perl programming
Posted by: arupratan biswas
Date: May 19, 2005 03:09AM

thanx it is working.but the emp_name field is not entering in the database...plz help

print "Content-type: text/html\n\n";
use DBI;
use CGI;
$q=new CGI;
#if ($emp_id eq '') {
# print "<html>";
# print "<body>";
# print "<form method='post' action=''>";
# print "<input type='submit' value='back to form'>";
# print "You have to enter emp_id";
# print "</form>";
# print "</body>";
# print "</html>";
$filename = $q->param("photo");
$photo =~ s/.*[\/\\](.*)/$1/;

$upload_filehandle = $q->upload("photo");

open UPLOADFILE, ">$upload_dir/$photo";


while ( <$upload_filehandle> )


$dbh = DBI->connect("dbi:mysql:test:","bobby","bobby");

my $sqlstatement = qq{INSERT INTO new_user1 (emp_name, emp_add, city, zip_code, dob, phone, photo) VALUES(?, ?, ?, ?, ?, ?, ?)};

#$sqlstatement="INSERT INTO new_user (emp_id, emp_name,emp_add,city,zip_code,dob,phone,photo) VALUES($emp_id,'$emp_name','$emp_add','$city',$zip_code,'$dob','$phone','$photo')";

$sth = $dbh->prepare($sqlstatement) or die "Could not prepare statement: $DBI::errstr";

$sth->execute($emp_name,$emp_add, $city,$zip_code, $dob, $phone, $photo) or die "Could not execute: $DBI::errstr";

#$sth->execute ||
#die " this is a wrong sql statement";
#print "Content-type: text/html\n\n";

print <<ENDHTML;

<title>Update details</title>
<h1><font color = "#008000"> Successfully Inserted</font></h1>

please help me

Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.