grax has asked for the wisdom of the Perl Monks concerning the following question:
Sorry about this but I am having a bit of a hard time at the moment with the syntax of some of the code. I have another problem, with the following errors: DBD::ODBC::st fetchrow_array failed: (DBD: no select statement currently executing err=-1) at line 39. Could ^ this be to do with the scope of the prepare and execute statments? Use of uninitialized value in bitwise and (&) at line 41. Please could you help, this is for my final year project at college and I would appreciate any help you can give me.#!usr/perl/bin use CGI; use DBI; $cgi_object = new CGI; $n = 0; $error_message = "No Records Found...Please Select Again"; # $search_type_local = $cgi_object->param(search_type); # $employee_first_name_local = $cgi_object->param(employee_first_name) +; # $department_type_local = $cgi_object->param(department_id); $search_type_local = 0; $employee_first_name_local = "Graham"; $department_type_local = 1; sub create_query_type_0; sub create_query_type_1; sub execute_query_type_0; sub execute_query_type_1; $dbh = DBI->connect("DBI:ODBC:detailsstore", "anonymous", "password") +or die "Couldn't connect to database"; if ($search_type_local == 0){ &create_query_type_0; &execute_query_type_0; if ($sth->rows == 0){ print $error_message; } else { while ($sth->rows ne 0 & $n < 25){ @data = $sth->fetchrow_array(); # line 39 $formmated = $data[0] & " " & $data[1] & " " & $data[2] +& " " & $data[3]; # line 41 print $cgi_object->textfield('detailsresults', $formmate +d, 30, 50); $n = $n + 1; } } } else { &create_query_type_1; &execute_query_type_1; if ($sth->rows == 0){ print $error_message; } else { while ($sth->rows ne 0 & $n < 25){ @data = $sth->fetchrow_array(); $formmated = $data[0] & " " & $data[1] & " " & $data[2]; print $cgi_object->textfield('detailsresults', $formmate +d, 30, 50); $n = $n + 1; } } } $sth->finish; $dbh->disconnect; sub create_query_type_0{ $sth = $dbh->prepare("SELECT employee_table.employee_first_name, em +ployee_table.employee_last_name, employee_table.employee_extension, e +mployee_table.department_id FROM employee_table WHERE (((employee_table.department_id)=?));") +; } sub create_query_type_1{ $sth = $dbh->prepare("SELECT employee_table.employee_first_name, em +ployee_table.employee_last_name, employee_table.employee_extension FROM employee_table WHERE (((employee_table.employee_first_name)= +?));"); } sub execute_query_type_0{ $sth->execute($employee_first_name_local) or die "Couldn't execute +statement"; } sub execute_query_type_1{ $sth->execute($department_type_local) or die "Couldn't execute stat +ement"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: ODBC errors
by busunsl (Vicar) on May 16, 2001 at 17:07 UTC | |
|
Re: ODBC errors
by c-era (Curate) on May 16, 2001 at 17:21 UTC | |
by the_0ne (Pilgrim) on May 16, 2001 at 17:56 UTC |