Not a OT but there is a good maillist specially for dbi users at
http://lists.perl.org/showlist.cgi?name=dbi-users

Anyway try this:

[snippet of your code with some modif]

#The CGI.pm module will take input from the form.
use CGI qw(:standard );
my $name=param("name");

#Connecting to DB
my $dbh = DBI->connect('DBI:ODBC:opal')
or die "Oops! Couldn't Connect".DBI->errstr;

#qq while building sql, will avoid you lot of head aches
my $sql=qq[ SELECT ContactName FROM Contacts WHERE ContactName='?' ];
my $sth = $dbh->prepare($sql)
or die "Couldn't prepare the statement:".$dbh->errstr;

my @row;
#DB now connected.  Run statements to find information.
#you don't need a my $name here.
$sth->execute($name);
while (@row = $sth->fetchrow_array){
        print "@row\n";
}
if ($sth->rows == 0){
        print "No names matched `$wholename'.\n\n";
}
$sth->finish;
print "\n";

HTH,

José.
 

> -----Original Message-----
> From: Tony Bandy [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, March 05, 2003 2:53 PM
> To: [EMAIL PROTECTED]
> Subject: DBI and getting values from the DB
> 
> 
> Hello everyone,
> 
> Please forgive in advance if this has already been 
> posted...fairly new to the list as have only been on it a 
> week. At this point I only get the digest, but just sent an 
> email to subscribe to the full list.
> 
> 
> I'm running apache 2.0x with mod_perl on a windows 2000 server.
> 
> I have a form page on the website where folks can enter a 
> name and then search a DB looking for that name and then give 
> back the results on another htm page.  I'm hoping this is a 
> common thing to do.
> 
> 
> Ok...the upshot is that using DBI:ODBC to access the access 
> db works. Also, I can use CGI.pm and know that the value from 
> the form is getting to the script.  
> 
> The problem lies in comparing the values from the form and 
> the values from the DB.  I keep getting no results.
> 
> 
> Here's a snippet of the code:
> 
> #The CGI.pm module will take input from the form.
> use CGI qw(:standard );
> my $name=param("name");
> 
> 
> 
> #Connecting to DB
> my $dbh = DBI->connect('DBI:ODBC:opal') or die "Oops! 
> Couldn't Connect".  DBI->errstr; my $sth = $dbh->prepare 
> ('SELECT ContactName FROM Contacts WHERE
> ContactName=?')
>       or die "Couldn't prepare the statement:" . $dbh->errstr;
> my @row;
> #DB now connected.  Run statements to find information. 
> $sth->execute(my $name); while (@row = $sth->fetchrow_array){ 
> print "@row\n"; } if ($sth->rows == 0) {
>     print "No names matched `$wholename'.\n\n";
>     }
> 
> $sth->finish;
> print "\n";
> 
> 
> -->Would anybody have any ideas?  I've got the Programming 
> the DBI book
> as well as some others, but since I'm new to this, I may be 
> leaving something totally out.
> 
> 
> Thanks in advance for your help and if this is a wrong post 
> or offtopic, please let me know.
> 
> thanks!
> 
> 
> 
> -- 
> ********************************************
> 
> Tony Bandy, MLS
> [EMAIL PROTECTED]
> Sys. Admin. OPAL
> OHIONET
> 1500 West Lane Ave.
> Columbus, OH  43221-3975
> 1-800-686-8975
> (614) 486-2966 X19
> (Emergency-->614-352-9409)
> http://www.ohionet.org
> http://cat.opal-libraries.org
> 
> IMPORTANT NOTICE:
> 
> This electronic message, including all attachments,
> is intended only for the individual/company/representative 
> addressed above, and may contain CONFIDENTIAL, PRIVILEGED, 
> and/or TRADE SECRET INFORMATION.  If you are not the intended 
> recipient, this notification is to let you know that any use, 
> distribution, or copying of this electronic message, 
> including any attachments, is strictly prohibited.
> 
> If you feel you have received this email in error, please contact 
> [EMAIL PROTECTED]
> 
> ********************************************
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


**** DISCLAIMER ****

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to