Re: Fetching values in Perl
Patrick Galbraith <[email protected]> Fri, 28 Sep 2007 12:05:21 -0400
| Newsgroups | gmane.comp.db.mysql.perl |
|---|---|
| Message-ID | <[email protected]> |
Greg Meckes wrote:
>Perhaps you could do it like this:
>
>$dbh= DBI->connect("dbi:mysql:dbname=$database;host=$hostname",
> "$username",
>"$password");
>
># Do some checking and untainting with $ARGV[0]
># I wouldn't just pass an argument like that
># directly to a query.
>
>my $arg = $ARGV[0]; # Check it here
>
>$statement = "SELECT patient_intime from $table_name where patient_intime=$arg)";
>
>
I would add to this the suggestion of using placeholders as well (to
ensure proper quoting, inection issues)
$statement = "SELECT patient_intime from $table_name where patient_intime= ?";
>my $sth = $dbh->prepare($statement) or die "Couldn't execute statement: " . $sth->errstr;
>$sth->execute;
>
>
$sth->execute($arg);
>my @data = ();
>
>while (@data = $sth->fetchrow_array()) {
>$patient_intime = $data[0];
>}
>
>--- padmaja <[email protected]> wrote:
>
>
>
>>Hi all,
>>I have written a query like this.
>>----------------------------------------------------------
>>
>>$dbh= DBI->connect("dbi:mysql:dbname=$database;host=$hostname", "$username",
>>"$password");
>>
>>$statement = "SELECT patient_intime from $table_name where
>>patient_intime=$ARGV[0])";
>>
>>
>>----------------------------------------------------------
>>I want all the "patient_intime" values to be retreived, where there are
>>other columns(fields) also.
>>Pls suggest me how to proceed.
>>
>>Thanks in advance.
>>Padmaja T N.
>>--
>>View this message in context:
>>http://www.nabble.com/Fetching-values-in-Perl-tf4534430.html#a12940280
>>Sent from the MySQL - Perl mailing list archive at Nabble.com.
>>
>>
>>--
>>MySQL Perl Mailing List
>>For list archives: http://lists.mysql.com/perl
>>To unsubscribe: http://lists.mysql.com/[email protected]
>>
>>
>>
>>
>
>
>
>
--
Patrick Galbraith, Senior Programmer
Grazr - Easy feed grazing and sharing
http://www.grazr.com
Satyam Eva Jayate - Truth Alone Triumphs
Mundaka Upanishad
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/[email protected]