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



#!/usr/bin/perl
print "Content-type: text/html\n\n";
use DBI;
use CGI;
$q=new CGI;
#$emp_id=$q->param('emp_id');
$emp_name=$q->param('emp_name');
$emp_add=$q->param('emp_add');
$city=$q->param('city');
$zip_code=$q->param('zip_code');
$dob=$q->param('dob');
$phone=$q->param('phone');
$photo=$q->param('photo');
#if ($emp_id eq '') {
# print "<html>";
# print "<body>";
# print "<form method='post' action='form1.pl'>";
# print "<input type='submit' value='back to form'>";
# print "You have to enter emp_id";
# print "</form>";
# print "</body>";
# print "</html>";
#}
#else
#{
$upload_dir="/httpd/html/guest4/load";
$filename = $q->param("photo");
$photo =~ s/.*[\/\\](.*)/$1/;

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


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

binmode UPLOADFILE;

while ( <$upload_filehandle> )
{
print UPLOADFILE;
}

close UPLOADFILE;

$dbh = DBI->connect("dbi:mysql:test:192.168.0.95","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;

<html>
<head>
<title>Update details</title>
</head>
<body>
<h1><font color = "#008000"> Successfully Inserted</font></h1>
</body>
</html>
ENDHTML
#}

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.