CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
help in retrieving data from the database



Jun 26, 2000, 1:21 PM

Post #1 of 2 (526 views)
help in retrieving data from the database Can't Post


I have kept database columns in an array and given the same name as i have given to the columns in the database) and i am trying to retrieve it.
Here is the code
@fields =
#the following are the columns in the #database,fields in the form have same names ("location","conferenceRoomName","roomNumber","overHead","slideProj","tv_Vcr","videoConference","seats");
$value = 'Lobby';
my $selStr ='';
my $colList = '';
my $recset = '';
my @vals = ();
my %fieldvals =();
for ($i=0; $i < scalar(@fields); $i++)
if ($fields[$i] =~ /date/) {
$colList .= "to_char($fields[$i], \'MMDDYYYY\') as $fields[$i]";
} #end if
else {
$colList .= "$fields[$i]"}
if ($i < scalar(@fields)-1)
{$colList .= ","}
$selStr ="Select $colList from ConferenceRooms where conferenceRoomName='$value'";
$recset = $syb->prepare($selStr);
@vals =$recset->fetchrow;
for ($i =0; $i < scalar(@fields); $i++) {
$fieldvals{$fields[$i]} = $vals[$i];
return %fieldvals;
The error is 'no statement executing'.

I want to retrieve the database value in a form.
For example,
if i use
<input type ="text" name ="columnname" value=$fieldvals{'columnname'}>
It will retrieve the database value from the hash.
I was stuck in the above code.

Please help me.


Jun 26, 2000, 3:45 PM

Post #2 of 2 (526 views)
Re: help in retrieving data from the database [In reply to] Can't Post

Preparing a query is not the same as exectuting a query.

$recset = $syb->prepare($selStr);

will not give you a record set. Consult the DBI documentation.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives