Hello, everyone. This may be a noobly question, but for the program I'm trying to create, I need the script to recieve input from an HTML script, use that input(in this case, a name) to search for corresponding information about that person in more than one table, and then return the results to the script, which, in turn, returns it to the web browser. The problem I'm having, however, is that at line 26, the error I'm getting is "too many arguments to connect". Why? What can I do differently to make this script work? The code is all shown below:
#!/usr/bin/perl use DBI; use warnings; my $firstname = $in{name}; my $db = "project_database"; my $host = "localhost"; my $user = "phillip"; my $pw = "steampunk333"; my $source = "DBI:mysql:database = project_database: host = localhost" +; my $contactid; my $dbh; print "Content-type:text/html\n\n"; $dbh = DBI_>connect($source,$user,$pw) or die "Can't connect to database: $DBI::errstr\n"; my $qfirstname = dbh_>quote($firstname); if ($firstname eq "Alan") {$contactid = "Alan W.";} elsif ($firstname eq "Jake") {$contactid = "Jake M.";} elsif ($firstname eq "Jessica") {$contactid = "Jessica S.";} elsif ($firstname eq "Jim") {$contactid = "Jim S.";} else {$contactid = "0"; print "<p><br />Error: No Matches were found for your search. Did you +include capital letters?</p><br /><br />";} if($contactid ne "0") {print "<br /><br /><p>This is the information returned from your quer +y:</p><br /><br />";} my $qcontactid = dbh_>quote($contactid); my $sth = $dbh_>prepare("SELECT lastname, date_first_employed, annual_ +salary FROM employees WHERE firstname = $qfirstname, SELECT * FROM employee_contacts WHERE contact_id = $qcontactid"); $sth_>execute( ); while (($lastname, $date_first_employed, $annual_salary, $date_first_e +mployed, $email_address, $home_phone_number, $emergency_phone_number) = $sth_>f +ethrow_array()) { print "<p>Employee ID: $id<br /><br />Last Name: $lastname<br /><b +r /> Date First Employed: $date_first_employed<br /><br /> Annual Salary: $annual_salary<br /><br />Contact ID: $contactid<br + /><br /> Email Address: $email_address<br /><br />Home Phone Number: $home_ +phone_number<br /><br /> Emergency Phone Number: $emergency_phone_number</p><br /><br />"; } $sth_>finish( ); $dbh_>disconnect( );
In reply to Too many arguments to connect-help? by steampunk333
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |