Perl scripts can't access Demon Access database to INSERT, DELETE, or UPDATE, but allows me to search and display??. . . HELP?
My INSERT, DELETE statements won't work and I dont know why . . . in fact it's driving me crazy. Please see my attached scrpits. I have been using the Open Perl IDE as well as Notebook++ to contrast and work on these scripts. As far as I can tell there is nothing the matter with them and it's driving me nuts. I have checked the file permissions for the database. I can search for information in the database and display all the items in the database but I cant INSERT, DELETE, or UPDATE.
Below find the link to my page (formatting of the page will be better when I can get some functionality): http://129.2.168.163/cm485a2/project1.html
Please help.
#!/usr/bin/perl -w
use strict;
#use DBI;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser); # provide descriptive error messages
use Win32::ODBC; #use ODBC package vs. DBI as in text
print header(); # print out "Content-Type: text/html\n\n"
# Get user's desired action from form
my $action = param('form_action');
# Connect to database
my $db = new Win32::ODBC("DSN=rreAccesscm485a2; UID=cm485a; PWD=kbradford68g")
or die Win32::ODBC::Error();
my $cust_ID;
my $fName;
my $mI;
my $lName;
my $street;
my $city;
my $state;
my $zip_Code;
my $DOB;
my $agent_ID;
my $home_Phone;
my $cell_Phone;
my $profession;
my $employer;
my $referrer;
$cust_ID = param('cust_ID');
$fName = param('first_Name');
$mI = param('mI');
$lName = param('last_Name');
$street = param('street_Name');
$city = param('city');
$state = param('state');
$zip_Code = param('zip_Code');
$DOB = param('DOB');
$agent_ID = param('agent_ID');
$home_Phone = param('home_Phone');
$cell_Phone = param('cell_Phone');
$profession = param('profession');
$employer = param('employer');
$referrer = param('referrer');
my $sql;
$sql = qq{INSERT INTO customer (Customer ID, first_Name, mI, last_Name,};
$sql .= qq{street_Name, city, state, zip_Code, DOB};
$sql .= qq{agent_ID, home_Phone, cell_Phone, profession, employer, referrer)};
$sql .= qq{ VALUES ('$cust_ID','$fName','$mI','$lName','$street','$city',};
$sql .= qq{'$state','$zip_Code','$DOB','$agent_ID','$home_Phone','$cell_Phone',};
$sql .= qq{'$profession', '$employer', '$referrer')};
#print '$sql=' . $sql . "\n";
if ($db->Sql($sql))
{
print "SQL Error: " . $db->Error() . "\n";
print qq(<html><head><title>Database Error</title>
</head>
<body><center><font size="6">Error with database call.</font>
<hr />
<font size="4" color="red">ODBC DB Error</font><br />
<font size="3">Please hit your <b>Back</b> button to re-enter the data and try again.</font></center>
</body>
</html>);
exit;
}
sub Display_P开发者_如何学运维age {
print qq(<html><head><title>Record Added!</title></head>
<body>
<center>
<font size="6">Record Added!</font>
<hr />
<font size="4">
<a href="http://129.2.168.163/cm485a2/project1.html">Back to Main Page</a>
</font><br />
</center>
</body>
</html>);
}
You need to quote Customer ID
or change the column name so that it doesn't contain spaces.
You also have to make sure you have a comma (,
) after every column. It's missing after the DOB
column name.
精彩评论