List:General Discussion« Previous MessageNext Message »
From:Aldrian Gintingsuka Date:March 25 1999 9:39am
Subject:Re: Extracting a given row using Perl API
View as plain text  
You forgot to include the quotes!!! They are necessary to parse your variable
as a string or otherwise it will interpreted as a table name.

my $sth = $dbh->prepare("SELECT first,last,phone FROM $table WHERE
phone_book.last='$FOO'");

========================================================================
Aldrian Gintingsuka -- Systems Consultant -- Mitra Integrasi Informatika
Phone: +62-21-251-1360 ext. 1414 -- Fax: +62-21-251-2748
Email: aldrian@stripped, aldrian@stripped
------------------------------------------------------------------------
Si tu es contre Dieu, tu es contre l'homme (Enigma: Sadeness part I)


On Wed, 24 Mar 1999, William R. Mattil wrote:

wrmattil> Can anyone tell me where the problem here is ???
wrmattil> 
wrmattil> 
wrmattil> Given a rather simple table phone
wrmattil> +----------+----------+------------+
wrmattil> |first     |last      |phone       |
wrmattil> +----------+----------+------------+
wrmattil> |Joe       |Blow      |800-555-1212|
wrmattil> +----------+----------+------------+
wrmattil> 
wrmattil> In this rather simplistic example:
wrmattil> 
wrmattil> my $sth = $dbh->prepare("SELECT first,last,phone FROM $table WHERE
wrmattil> phone_book.last='Blow'");
wrmattil> 
wrmattil> works while the following does not;
wrmattil> 
wrmattil> my $sth = $dbh->prepare("SELECT first,last,phone FROM $table WHERE
wrmattil> phone_book.last=$FOO");
wrmattil> 
wrmattil> Where $FOO = 'Blow'; And the error message returned is as follows:
wrmattil> 
wrmattil> DBD::mysql::st execute failed: Unknown column 'Blow' in 'where clause'
wrmattil> at ./find-record line 23.
wrmattil> 
wrmattil> I'm sure that I am making a grievous error here but just can't see it.
wrmattil> Can anyone shed some light on this ???
wrmattil> 
wrmattil> 
wrmattil> Thanks in Advance
wrmattil> 
wrmattil> Bill



Thread
Extracting a given row using Perl APIWilliam R. Mattil25 Mar
  • Re: Extracting a given row using Perl APIAldrian Gintingsuka25 Mar
  • Re: Extracting a given row using Perl APIVivek Khera25 Mar
  • Re: Extracting a given row using Perl APIChris25 Mar
  • Re: Bug reportFred van Engen16 Feb
Re: Extracting a given row using Perl APIDerick H Siddoway25 Mar
Re: Extracting a given row using Perl APIVivek Khera25 Mar