Geowil
12-07-2008, 01:03 PM
I gave up on getting POST and php to work but I was able to get it working with a cgi script.
So now I am implementing my sql connection subroutine and am passing the POSTed variables into it. The only problem is the subroutine wont take all the arguments for whatever reason.
here is the call:
connect($fName,$fName2,$email);
and here is the sub definition:
[code]
sub connect {
my($firstname, $lastname, $email) = @_;
$link = "DBI:mysql:database_name:localhost";
my $link2 = DBI->connect($link, "username", "password") || die "Can't Connect";
## insert fill-in form input into database:
my $sel = $link2->prepare("INSERT INTO 'testusers' VALUES($firstname,$lastname, $email)");
$sel->bind_param(1, $firstname);
$sel->bind_param(2, $lastname);
$sel->bind_param(3, $email);
$sel->execute() && $sel->finish();
$result = mysql_query($sel);
if ($result) {
print header;
print "Account created successfully!";
print end_html;
}
else {
print header;
print "Creation Failed for following reason: ";
print(mysql_error());
print end_html;
}
$dbh->disconnect;
}
here is the error out put from that page:
Software error:
Too many arguments for connect at testcgi.cgi line 17, near "$email)"
Execution of testcgi.cgi aborted due to compilation errors.
why is it spitting that out? Are subs limited to only 2 arguments or is something else wrong with the script that I dont see?.
So now I am implementing my sql connection subroutine and am passing the POSTed variables into it. The only problem is the subroutine wont take all the arguments for whatever reason.
here is the call:
connect($fName,$fName2,$email);
and here is the sub definition:
[code]
sub connect {
my($firstname, $lastname, $email) = @_;
$link = "DBI:mysql:database_name:localhost";
my $link2 = DBI->connect($link, "username", "password") || die "Can't Connect";
## insert fill-in form input into database:
my $sel = $link2->prepare("INSERT INTO 'testusers' VALUES($firstname,$lastname, $email)");
$sel->bind_param(1, $firstname);
$sel->bind_param(2, $lastname);
$sel->bind_param(3, $email);
$sel->execute() && $sel->finish();
$result = mysql_query($sel);
if ($result) {
print header;
print "Account created successfully!";
print end_html;
}
else {
print header;
print "Creation Failed for following reason: ";
print(mysql_error());
print end_html;
}
$dbh->disconnect;
}
here is the error out put from that page:
Software error:
Too many arguments for connect at testcgi.cgi line 17, near "$email)"
Execution of testcgi.cgi aborted due to compilation errors.
why is it spitting that out? Are subs limited to only 2 arguments or is something else wrong with the script that I dont see?.