#!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"; }
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.

In reply to ODBC errors by grax

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.